iosiphoneswiftapple-watchwatchos-2

Easiest way to share data between iphone and apple watch


I have stored simply data for table view in UserDefaults for persistence. Now I am working on app for Apple Watch and I want to sync that data in UserDefaults with Apple Watch.

Sample use case for what I need. I add record on iPhone, than I close the app. For example in one hour I will open app on Apple Watch and I want to have that record from iPhone on Apple Watch.

Whats the best way how to sync that data? Thank you for your time!


Solution

  • For sharing data between iOS app and Watch, see the Sharing Data section of App Programming Guide for watchOS:

    https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/SharingData.html#//apple_ref/doc/uid/TP40014969-CH29-SW1