简体   繁体   中英

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...

I am trying to access a plist file stored in the NSDocumentDirectory but am having no luck. The today extension is all set up correctly with a separate target in the project and my bundle identifier starts with '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. 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. You could use NSUserDefaults to share the data.

Read it here Sharing Data with Your Containing App

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM