ImWH
ImWH

Reputation: 944

In today extension, how could i get data from the main application?

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

Answers (2)

user5197790
user5197790

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

Mukesh
Mukesh

Reputation: 3690

Create Apps Groups Under Targets->Capabilities as shown in below screenshot,it should be uniqueenter image description here

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

Related Questions