#Conform to the Protocol
First, on our model we conform to the MTLManagedObjectSerializing
protocol. This has 2 required methods, but we’ll actually need to implement 3 methods.
1 | #pragma mark - MTLManagedObjectSerializing |
This is all we need to enable the feature for our models, including updating the records if they exist already.
#Serializing to Core Data
Given the we’ve converted from a JSON document to our model, we also want to convert that model into an NSManagedObject
for saving. We can do this for each record by using the MTLManagedObjectAdapter
class:
1 | [self fetchEpisodesWithCompletion:^(NSArray *episodes) { |
Refer to http://nsscreencast.com/episodes/120-mantle-with-core-data