在xcode中建模的新属性导致NSLocalizedDescription - 无法序列化托管对象

时间:2017-02-13 00:57:06

标签: ios swift2.3 github-mantle

@interface ModelClass : SCObject
@property (strong, nonatomic) NSString *scObjectID;
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *videoUrlHLS;
@property (strong, nonatomic) NSString *fileUrlDirect;

@implementation ModelClass

+ (NSDictionary *)JSONKeyPathsByPropertyKey
{
    return @{ Key(ModelClass, scObjectID) : @"MediaId",
              Key(ModelClass, title) : @"Title",
              Key(ModelClass, videoUrlHLS) : @"VideoUrlAppleHLS",
              Key(ModelClass, fileUrlDirect) : @"FileUrlS3Direct"
}

fileUrlDirect属性是新属性,更新了JSONKeyPathsByPropertyKey以将json属性转换为模型属性

@property (strong, nonatomic) NSString *fileUrlDirect;
Key(ModelClass, fileUrlDirect) : @"FileUrlS3Direct"

当我跑步时

[MTLManagedObjectAdapter managedObjectFromModel:instanceOfModelClass insertingIntoContext:context error:error];

我收到了

[0] (null)  @"NSLocalizedDescription" : @"Could not serialize managed object"   
[1] (null)  @"NSLocalizedFailureReason" : @"No property by name \"fileUrlDirect\" exists on the entity."    

我已经调试并确认instanceOfModelClass具有新属性但我无法弄清楚为什么我收到此错误

我是ios开发的新手,我猜这里还有更多工作要点,但我不知道是什么

1 个答案:

答案 0 :(得分:0)

您在核心数据实体中缺少名为fileUrlDirect的属性,而您正在将instanceOfModelClass映射到该属性。