我开始按照本教程将 Core Data 与我的 Mantle 对象 (MTLModel) 结合使用:http://chroman.me/core-data-and-mantle-one-to-many-relationship/
这篇文章说:
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
所以,我有两个具有相同属性的类:
- TrackMTL.m (MTLModel)
- Track.m (NSManagedObject)
我正在寻找一个无需为同一对象创建两个模型且无需使用像 Overcoat 这样的包装器的解决方案.
最佳答案
您不必使用 2 个类,只需将其添加到您的 MTModel 中即可:
<MTLJSONSerializing, MTLManagedObjectSerializing>
对于您必须实现的属性:
+ (NSDictionary *)managedObjectKeysByPropertyKey
关于objective-c - 地幔和核心数据 : Only one Model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28720920/