本文介绍了地幔和核心数据:只有一种模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本教程之后,我开始将Core Data与Mantle对象(MTLModel)结合使用: http://chroman.me/core-data-and-mantle-one-to-many-relationship/

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/

本文说:

所以,我有两个具有相同属性的类:

So, I have two class with the same properties:

  • TrackMTL.m(MTLModel)
  • Track.m(NSManagedObject)

我正在寻找一种une解决方案,而不必被迫为同一对象创建两个模型,并且无需使用大衣.

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

推荐答案

您不必使用2个类,只需将其添加到您的MTModel中:

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

这篇关于地幔和核心数据:只有一种模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 13:37
查看更多