简体   繁体   中英

UIPasteboard.general.string takes too long

In my UI test, I have a test where I am using the UIPasteboard to throw the input around. Just before I use it, I store the current value of the pasteboard into a local temporary variable like so: let currentClipboard = UIPasteboard.general.string ?? "" let currentClipboard = UIPasteboard.general.string ?? "" and it will be restored again at the end of the test like so: UIPasteboard.general.string = currentClipboard . However, sometimes the let currentClipboard = UIPasteboard.general.string ?? "" let currentClipboard = UIPasteboard.general.string ?? "" line takes forever to complete, if at all. I've waited like 1-2 minutes and it still stuck there. I know this because I actually added a breakpoint right below that line and it was never called. Can anybody tell me what's wrong with my code? Thanks.

I've faced the same issue in the simulator only. If you're testing in simulator then just reset the simulator and it'll start working fine. And I didn't find this type of issue in the real device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM