RestKit:嵌入在NSObject中的NSManagedObject

时间:2012-07-02 07:12:16

标签: ios restkit

Book是普通的NSObject,而AuthorNSManagedObject,我正在Book#author映射到Author Book.objectMapping 1}},问题是我将托管对象嵌入到普通对象中,RestKit是否可能将嵌入的author映射到CoreData对象中?

//Book.m
+ (RKObjectMapping *)objectMapping {
        RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Book class]];
        mapping.rootKeyPath = @"book";
       [mapping mapKeyPathsToAttributes:@"book_id", @"bookID",
                                        @"author_id", @"authorID", nil];

       [mapping mapKeyPath:@"author"
            toRelationship:@"author"
               withMapping:[Author objectMapping]];
}

1 个答案:

答案 0 :(得分:0)

要检查的一件事是您将类与核心数据模型中的实体相关联。拉起Entity Inspector并确保将Class设置为Author。如果你没有设置类,它最终会将你的对象加载为NSManagedObjects。