Q:

Core Data for local storage and displaying temporary data from server - what is best design

I'm still new to Core Data, so forgive the question.
I'm building an app that (to make it simple) allows people to "challenge" themselves and others. I need to store locally the challenges the user has already accepted, so that he can browse their details offline. However, when the app is online I'm making requests to the server to display the available challenges, the new details of the already accepted challenges, etc. So some syncing will be needed, but I`m trying to keep that to the minimum.
Now my problem is how to architecture the data. Should I:
(1) Have a core data model only for the data that is stores on the device; then just build model classes for the challenges that are being parsed from the server, and display an array of Challenge objects in my table views?
(2) Have a single core data model for both, but somehow distinguish between the Challenges that are local to the ones that are transient?
(3) Have two persistent stores, one for each purpose?
Options 2 and 3 obviously have the advantage of using NSFetchedResultsController, but may be more complex to code and maintain.
And, as to the syncing problem, should I:
(4) Keep a timestamp of the last time each of my local Challenges were updated, and match these with the timestamps on the server, to see if I need to push new details to the server or not?
(5) Save an array of keypaths and the changes, and then push that to the server once internet connection is available again.
What would be the best approach to solve these two problems.
Thanks a lot!

A:

Since this is a design question and design is an art in a sense that there are always more than one approach, here is what I would probably do.
I would create a model to store both local and available challenges distinguishing them by some property. When there is no network connectivity, I possibly could choose to filter out all remote challenges not to show cached (or transient as you put it) challenges. When the connectivity is resumed or when sync takes place, I would check if I need to update any of the challenges either on the server or locally.
Timestamps is a good way to check for modification time of the entity. If you need to do property by property comparisons for conflict resolution, you could use checksums such as crc32 or md5 hash to speed up comparison of binary data should you have any.
Even with timestamps it is possible that an object was touched, but the values saved remained actually the same, so checksum could be used to detect if actual changes were made to the object. You can use NSKeyedArchiver to serialize an object into an NSData and calculate a checksum on it. I have found this approach reliable.

