【发布时间】:2019-06-26 07:52:42
【问题描述】:
我正在尝试在 AppDelegate 的 applicatioDidEnterBackground 部分中阅读粘贴板 5 次。要打印字符串,我使用print(UIPasteboard.general.string!),但它仅适用于函数,不适用于其他嵌套函数。让我解释一下:
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
print(UIPasteboard.general.string!) //here it works perfectly and prints the string correctly
for _ in 0...5 {
print(UIPasteboard.general.string!) //here it returns nil
}
}
我已经阅读了与我的类似的其他问题,但没有一个对我有帮助。我不知道这是否是安全限制,但如果您能帮助我,我将不胜感激????
【问题讨论】:
标签: swift appdelegate uipasteboard ios-background-mode