1

With the new architecture of WatchOS2, watch apps can run stand alone without a connection to the iPhone. What would be the best practice to store a small amount of data (by example a NSMutableDictionary), which normally would be stored in the NSUserdefaults. NSUserdefaults is not working on WatchOS2.

Concrete: When the app runs for the first time some data are collected, stored in the NSUserdefaults on the iPhone and than transferred via WatchConnectivity to the Apple watch.

If the user runs the next time the app stand alone on the Apple watch I need that data ton be retrieved.

Ing. Ron
  • 2,005
  • 2
  • 17
  • 33
  • 1
    You should be able to use NSUserDefaults I tried it and it works for me. If you add any code pieces about using NSUserDefaults maybe we can find a way what isn't working. – Candost Sep 10 '15 at 13:23
  • You are right, it is working. I do not checked it before because I was reading in the Apple documentation that it is not working. But the documentation said the sync between Container does not work. I understand that wrong. In the meantime I found an other entry on that topic here on stack overflow which also answered my question: http://stackoverflow.com/questions/30851729/nsuserdefaults-not-working-on-xcode-beta-with-watch-os2 – Ing. Ron Sep 10 '15 at 14:21
  • I saw this question-answer but thought you had different issue. I wrote an answer and please accept it, so other users can find the solution easily. – Candost Sep 10 '15 at 17:52

1 Answers1

4

You can use NSUserDefaults to store data locally. To share your data between Apple Watch and iPhone, you should use WatchConnectivity. As you said in comment, there is an another question-answer about NSUserDefaults here.

Community
  • 1
  • 1
Candost
  • 1,029
  • 1
  • 12
  • 28