UIPasteboard string returning null from Today extension

时间秒杀一切 提交于 2019-12-22 08:53:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!