Book
是普通的NSObject
,而Author
是NSManagedObject
,我正在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]];
}
答案 0 :(得分:0)
要检查的一件事是您将类与核心数据模型中的实体相关联。拉起Entity Inspector并确保将Class设置为Author。如果你没有设置类,它最终会将你的对象加载为NSManagedObjects。