在 iphone 和 Apple Watch 之间共享数据的最简单方法

Easiest way to share data between iphone and apple watch

我在 UserDefaults 中存储了 table 视图的简单数据以保持持久性。现在我正在为 Apple Watch 开发应用程序,我想将 UserDefaults 中的数据与 Apple Watch 同步。

我需要的示例用例。我在 iPhone 上添加记录,然后关闭应用程序。例如,一小时后我将在 Apple Watch 上打开应用程序,我想在 Apple Watch 上获取来自 iPhone 的记录。

同步数据的最佳方式是什么?感谢您的宝贵时间!

要在 iOS 应用程序和 Watch 之间共享数据,请参阅 watchOS 应用程序编程指南的共享数据部分:

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