Damien Romito
Damien Romito

Reputation: 10065

Mantle and Core Data : Only one Model

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:

I'm looking for une solution without be forced to create two Model for the same Object and without use wrapper like Overcoat.

Upvotes: 4

Views: 1166

Answers (1)

Nabil El
Nabil El

Reputation: 972

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

Upvotes: 2

Related Questions