1

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!

Kampai
  • 22,848
  • 21
  • 95
  • 95
Joe Barbour
  • 842
  • 9
  • 14

1 Answers1

2

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

Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
  • That was my question yes. So there is no way to access any file within the documents directory via the extension because there is no direct access supported? – Joe Barbour Sep 16 '14 at 17:06
  • Ya. AFAIK not possible. You have to use NSUserDefaults that what i find on the apple docs – Anil Varghese Sep 17 '14 at 04:45