how to make watchkit extension app and my iphone app share the same icloud databases

走远了吗. 提交于 2019-12-13 04:35:13

问题


Im trying to make my app for the apple watch but I am running into a problem with the cloud containers. When I created cloud kit for the watch extension it created its own container/database so now Im trying to get them both to share the same one. Ive tried to specify the custom container I want but it is not working. Please Help!


回答1:


Since your watch app will use a specific CloudKit container you have to initiate your container using the identifier. You can not use the defaultContainer.

So you have to make sure that instead of CKContainer.defaultContainer() you use: CKContainer(identifier: "iCloud.com.Moodler.Moodler")

The rest of your code will remain the same.




回答2:


Apple has provided a sample app for iCloud data sharing across all targets. Search for ‘lister watchkit’. They mentioned setup procedure in detailed document - ‘iOS and Watch Quick Start’

Common bundle identifier prefix is shared across all targets e.g., com.example.myApp. This prefix can be used to create a iCloud Document identifier.



来源:https://stackoverflow.com/questions/30458459/how-to-make-watchkit-extension-app-and-my-iphone-app-share-the-same-icloud-datab

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