Save and Load Data on Today Extensions (iOS 8)

后端 未结 5 1183
陌清茗
陌清茗 2020-12-19 05:10

Is it possible to save and load data on Today Extension using NSUserDefaults? After closing the Notification Center, the widget behaves like an app which is terminated, so a

5条回答
  •  太阳男子
    2020-12-19 05:34

    You need to use app group identifier instead of com.* For instance:

    NSUserDefaults *shared = [[NSUserDefaults alloc]initWithSuiteName:@"group.company.appgroup"];
    

    Don't forget to synchronise when you store data

    [shared synchronize];
    

提交回复
热议问题