Share datas between two apps with iOS 8 App Groups (using NSUserDefaults)

后端 未结 2 1227
挽巷
挽巷 2020-12-06 01:55

I wonder if we can share datas between apps with the new iOS 8 feature : App groups (using NSUserDefaults) - Or if App Groups only share datas between the main app and its e

2条回答
  •  长情又很酷
    2020-12-06 02:26

    Check out this thread on the Apple Developer Forums: https://devforums.apple.com/message/977151#977151

    I believe that both instances need to use the group ID (initializing with initWithSuiteName:) or else they are reading/writing to different user defaults sets.

    So your Swift code would change to:

    var userDefaults = NSUserDefaults(suiteName: "group.com.company.myApp")
    userDefaults.setBool(true, forKey: "Bool")
    userDefaults.synchronize()
    

提交回复
热议问题