NSUserDefaults, Settings.bundle and App groups

前端 未结 1 613
梦谈多话
梦谈多话 2021-02-14 08:14

I have an app with 2 targets, the main app and a Today extension - to share settings between these targets I\'ve switched on the App Groups Capabilities, added a group gro

1条回答
  •  心在旅途
    2021-02-14 08:28

    Eventually found the answer in the comments section of the original linked website.

    to target App-Group settings instead of the App Targets user defaults, all you need to do is add “ApplicationGroupContainerIdentifier” as a key to the Root.plist of your Settings Bundle and set its value as your App-Group identifier

    So, after adding the following to my Settings.Bundle Root.plist, both my main App and Today Extension are accessing the same user defaults.

    enter image description here

    0 讨论(0)
提交回复
热议问题