Core Data and Watch OS

I have an iPhone app that uses Core Data. I would like to replicate the structure on the watch app extension. I can share the data structure between the two targets but I am not clear on how to implement the core data stack on the watch.
The idea is that I would send changes updates and changes from the iOS app to the watch and it would basically keep both core data stores in sync.
I just spent the last 4 hours trolling the different sources out there, but have found no clear example for WatchOS 3 that would show me how to create and populate core data on the watch.
Does anyone have a working example?

1 Like

@cretech Thanks very much for your question! Core Data is meant for persistence for iOS, however, when it comes to the Apple Watch, I would seriously advise you to ensure that you minimize data storage on the watch, and look to putting as much storage either on the iPhone, or to the cloud. Because the watch is so limited in capacity, seriously consider other options for persistence when specifically dealing with the watch. What I would suggest is to treat the app as one and the same, and treat the watch as merely an extension of the phone. Thus, you maintain Core Data on the device, and if you need to make a distinction with data received from the watch, then perhaps add a property to the Core Data entity that you’re working with to distinguish data received on the iPhone vs data received from the Apple Watch. This way, you have one data model, but are able to still distinguish the data that you are persisting. The less data you store on your watch, the better!

Having said that, I unfortunately don’t have an example of using Core Data on the Apple Watch, and I think perhaps that should be a telling sign that this may not be a good idea. :slight_smile:

I hope this helps!

All the best!