问题
I need to create a new instance of an NSManagedObject subclass, which I then intend to POST using
- (void)postObject:(id<NSObject>)object usingBlock:(RKObjectLoaderBlock)block
How do I create the object? Do I use this method?:
+ (id)insertNewObjectForEntityForName:(NSString *)entityName inManagedObjectContext:(NSManagedObjectContext *)context;
If I am supposed to use insertNewObjectForEntityName
, how do I get context
?
回答1:
I figured it out myself.
Say that my NSManagedObject subclass was named Blah. I can create an instance of Blah like this:
Blah *blah = [Blah object];
来源:https://stackoverflow.com/questions/12309672/restkit-0-10-1-how-do-i-create-a-new-instance-of-an-nsmanagedobject-subclass