Search code examples
watchkit

Storage of Variables Across iOS and WatchOS


Is there any way to store a variable that can be accessed and changed by both the iOS and WatchOS applications? For example, a score set on one device, could be read, displayed and updated on the other. What is the most efficient way to do this?


Solution

  • Have a look at the Sharing Data section of Apple's App Programming Guide for watchOS.

    If you want to share files, use a shared group container, but if you just want to share variables, which you only need at runtime, use the WatchConnectivity framework.