I am importing book records from JSON into NSManagedobjects that have their own attributes but also relationships to other entities, authors and publishers.
For each book item that comes down from the cloud via JSON, I create a new bookFromServer object. I store the attributes from JSON into this object. This is simple enough with title, bookid etc.
However, the JSON also contains other information that properly belongs in other entities, ie publisher publisher name, publisher address, author first name author last name, author date of birth etc.
My question, is whether I also have access to "phantom" or uninstantiated managedobjects of the entitites with which my object has a relationship? Or do I need to create properties in the object file for each and every attribute.
Here is the NSObject file for BookFromServer
#import <CoreData/CoreData.h>
@class Books;
@class Authors;
@class Publishers;
@interface BookFromServer : NSObject
@property (nonatomic, retain) NSNumber * bid;
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSNumber * authorid;
@property (nonatomic, retain) NSNumber * publisherid;
//this is relationship
@property (nonatomic, retain) Authors *author;
//this is relationship
@property (nonatomic, retain) Publishers *publisher;
@end
I would like to store author info in something like author.firstname, not as a separate authorfirstname property in books. So my question is when I instantiate a book object, do I get the use of the attributes in the objects available through the relationships?