[英]Today Extension (App Groups)
I have been browsing the Apple Documentation for hours now and there is so little on the Today Extension, so I just can't get to the bottom of this problem... 我已经浏览了几个小时的Apple文档,“今日扩展”上的内容很少,所以我无法深入了解这个问题...
I am trying to access a plist file stored in the NSDocumentDirectory
but am having no luck. 我正在尝试访问存储在
NSDocumentDirectory
的plist文件,但是没有运气。 The today extension is all set up correctly with a separate target in the project and my bundle identifier starts with 'group.' 今天的扩展名已正确设置,并且在项目中具有单独的目标,并且我的捆绑包标识符以“ group”开头。 but I get a null value every time?
但是我每次都会得到一个空值?
This is my code... 这是我的代码...
NSURL *storeURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group.com.ORGANISATION.APPNAME.wigit"];
NSString *string = [storeURL.path stringByAppendingPathComponent:@"DataFile.plist"];
NSMutableArray *content = [NSMutableArray arrayWithContentsOfFile:filePath];
Thank you for your help in advance! 提前谢谢你的帮助!
If I understand your question correctly, you are trying to share data between the AppExtension and the containing app. 如果我正确理解您的问题,则您正在尝试在AppExtension和包含的应用程序之间共享数据。 By default your extension and its containing app have no direct access to each other's containers.
默认情况下,您的扩展程序及其包含的应用程序无法直接访问彼此的容器。 So the
NSDocumentDirectory
of your app will not be accessible form the extension. 因此,您的应用程序的
NSDocumentDirectory
将无法通过扩展名访问。 You could use NSUserDefaults
to share the data. 您可以使用
NSUserDefaults
共享数据。
Read it here Sharing Data with Your Containing App 在此处阅读与共享应用程序共享数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.