I have an iOS app which uses on-device database. I want to access the database from my App Extension. The database access requires a path which I insert into the NSUserDefaults as shown below. I first run the App Target which triggers the following code.
NSUserDefaults *userDefaults = [[NSUserDefaults alloc] init];
[userDefaults setValue:databasePathFromApp forKey:@"DatabasePath"];
[userDefaults synchronize];
Then I run the Todays Extension which accesses the NSUserDefaults set by the Main App.
NSUserDefaults *userDefaults = [[NSUserDefaults alloc] init];
_databasePath = [userDefaults valueForKey:@"DatabasePath"];
The _databasePath is always nil. What am I doing wrong? Do I have to use App Groups to share database between the app and the todays extension.