我已经阅读了很多有关是否URLForUbiquityContainerIdentifier:应该在主线程之外调用的相互矛盾的信息.在很多Apple的文档中,他们总是在主线程上调用这个方法.但是,我还读到,调用此方法可能会阻塞很长时间.
每个人的想法是什么?在主线程中调用它并不担心或是,总是在另一个线程中进行此调用?
我正在尝试获取我的容器 ID 的 url,但该方法不断返回nil。
我做了以下事情:
iCloud Key-Value Store添加到权利文件中。我的代码是:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Override point for customization after application launch.
let cloudURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)
print(cloudURL as Any)
return false
}
Run Code Online (Sandbox Code Playgroud)
我已经查找了几乎所有与此问题相关的问题并尝试了答案,但它不起作用。