I have successfully shared data between my App and its Today Extension via userDefaults, but I am having trouble when it comes to actual files located in the app's Documents folder.
When I use this code in my app:
var documentsDir:NSString = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
it returns:
/var/mobile/Containers/Data/Application/296494AA-946C-40E0-8646-F0895E131DCB/Documents/
but in the extension it returns:
/var/mobile/Containers/Data/PluginKitPlugin/AB484342-537A-4CE7-9EF3-F2CAE352C8A3/Documents/
and obviously, the files are not there.
I read somewhere that I should use:
let containerURL = manager.containerURLForSecurityApplicationGroupIdentifier("group.com.company.app")
let filePath = containerURL.path
but it returns:
/private/var/mobile/Containers/Shared/AppGroup/CD7CF610-EB5F-4246-8D30-D7F8BFA6A219
which didn't work either.
How can I get my iOS 8 Today Extension to read its container app's files located in Documents?
Thanks!