I've been going through all of the Apple documents and videos related to creating watchOS apps, complications and the like. Carefully studying the flow of updating data and the user interface - yet there's one thing I didn't manage to figure out.
In all of the related videos and documents, it is explained that once a URLSession download task ends, the app should update it's data model and request the system to schedule a snapshot update.
My question is this: where should the data model be stored/persisted? Is it even necessary? Should I use Core Data? An in-memory singleton object? SQLite? UserDefaults? A simple JSON file? What is the preferred way of keeping your data model when writing apps for watchOS?
I am looking to store an array of very simple objects (e.g. a list of contacts, where each contact has a name, an address and a phone number, all of them represented as String
objects)
Here's a link to the WWDC 2016 session named "Keeping Your Watch App Up to Date" that explains most of the tasks and best practices I've mentioned - WWDC 2016: Keeping Your Watch App Up to Date
It is typically best practice to be storing persistent data for watchOS in the cloud or on a companion iPhone app. My guess is that what your source refers to by 'data model' is the data in active storage, i.e. when the app is open. You shouldn't be storing redundant data locally if you don't need to, esp. not for watchOS.
All that being said, watchOS does have access to CoreData and NSCoding methods. I'm not sure about NSUserDefaults - but I wouldn't use that anyway for data storage. (This is a general principle for iOS as well: CoreData is used for data, and UserDefaults for user preferences.) Here is a similar thread explaining how that's done.
But I would highly recommend finding an alternative before storing data on the watch - there just isn't a whole lot of persistent storage space available on there.
EDIT: Check out Apple's WatchKit docs for more details on your options.