0
@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 开发的新手,我猜还有更多的东西需要连接才能让它工作,但我不确定是什么

4

1 回答 1

0

fileUrlDirect您在映射到的核心数据实体中缺少具有名称的属性instanceOfModelClass

于 2017-02-18T00:29:59.557 回答