问题
It seems that in iOS 9/Xcode 7 beta 5, I am unable to access
[[UIPasteboard generalPasteboard] string];
from my Today widget extension as every time no matter the contents, it returns (NULL). I looked through the release notes and I did not see anything regarding this.
Any ideas?
回答1:
It seems to be an undocumented bug with iOS 9 beta 5, in particular, the iOS runtime. Same code works with normal app on iOS 9 beta 5, and today widget in iOS 8.x devices.
回答2:
My app, which is a password manager, needs to check the pasteboard's contents while in background to clear it after a while, so as to limit the users's password exposure.
The main app, while on background, is also getting nil from the [[UIPasteboard generalPasteboard] string]
call. When it comes back to the foreground, it gets the correct data.
Because of that, I suspect this is a new and undocumented security/privacy feature and that there will be no "fixing".
来源:https://stackoverflow.com/questions/31885220/uipasteboard-string-returning-null-from-today-extension