Reputation: 944
In my app's today extension, I want to get some text from the main app. I tried using NSUserDefault and Notification, nothing I could get. I don't want to copy the same lengthy code from the main app, so how could I do? Thanks!
Upvotes: 0
Views: 1119
Reputation:
If you enrolled Apple Developer program, the app group is a good way,or build a new target to share the data.
Upvotes: 1
Reputation: 3690
Create Apps Groups Under Targets->Capabilities as shown in below screenshot,it should be unique
Now u can store info NSUserDefaults
,but u have to use different methods for storing info with app groups name.Below i have given an example
NSUserDefaults *sharedDefault= [[NSUserDefaults alloc] initWithSuiteName:@"group.DigitalAnniversaries"]
[sharedDefault setValue:@"3" forKey:@"notification"]
Upvotes: 2