0

Book是一个普通的NSObjectAuthor而是一个NSManagedObject,并且我正在映射Book#authorAuthorBook.objectMapping问题是我将一个托管对象嵌入到一个普通对象中,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]];
}
4

1 回答 1

0

One thing to check is that you associated the class to the entity in your Core Data Model. Pull up the Entity Inspector and make sure you set the Class to Author. If you don't set the class it'll end up loading your objects as NSManagedObjects.

于 2012-07-19T14:27:37.007 回答