Key data not storing to iCloud with NSUbiquitousKeyValueStore.defaultStore

≡放荡痞女 提交于 2019-12-10 18:17:43

问题


So I have a simple goal, just to get this working. So theoretically if you ruined this.

  1. Triggered save players
  2. waited a bit
  3. Deleted the app
  4. Rebuilt (downloaded)
  5. Triggered restore then the word "MEDO" would print to the console

But instead it is null, making me pretty sure that it is not saving to iC cloud some reason. I followed this tutorial. Perhaps it is too outdated to work?

func c_restoreCharecters()
    {
        let icloud = NSUbiquitousKeyValueStore.defaultStore()
        println(icloud.objectForKey("username"))
    }

    func c_savePlayers()
    {
        let icloud = NSUbiquitousKeyValueStore.defaultStore()
        icloud.setObject("MEDO", forKey: "username")
        println(icloud.synchronize())
    }

Obviously I am going to use this concept for something completely different in the future, but I have to get the basics down first!

Some other stuff: iCloud set up in my settings: My Entitlements file:

来源:https://stackoverflow.com/questions/33590375/key-data-not-storing-to-icloud-with-nsubiquitouskeyvaluestore-defaultstore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!