问题
I'm starting to use Core Data with my Mantle Object (MTLModel) following this tutorial: http://chroman.me/core-data-and-mantle-one-to-many-relationship/
This article said :
Since model classes inherit from NSManagedObject, which means that they can’t inherit from MTLModel, we need to use separated classes for Mantle and Core Data
So, I have two class with the same properties:
- TrackMTL.m (MTLModel)
- Track.m (NSManagedObject)
I'm looking for une solution without be forced to create two Model for the same Object and without use wrapper like Overcoat.
回答1:
You don't have to use 2 classes, just add this to your MTModel :
<MTLJSONSerializing, MTLManagedObjectSerializing>
and for the properties your have to implements this :
+ (NSDictionary *)managedObjectKeysByPropertyKey
来源:https://stackoverflow.com/questions/28720920/mantle-and-core-data-only-one-model