Saturday, 15 February 2014

ios - CoreData: ObjectID Error: "No known class method for selector 'managedObjectContext' -



ios - CoreData: ObjectID Error: "No known class method for selector 'managedObjectContext' -

@implementation firstscene ... - (void)nextscene { meetings *meetings = (meetings *) [nsentitydescription insertnewobjectforentityforname:@"meetings" inmanagedobjectcontext:self.managedobjectcontext]; nsmanagedobjectid* objectid = [meetings objectid]; [secondscene setobjectid:objectid]; } ... @end @implementation secondscene .... - (void)viewdidload { [super viewdidload]; self.managedobjectcontext = [(stappdelegate *)[[uiapplication sharedapplication] delegate] managedobjectcontext]; } + (void)setobjectid:(nsmanagedobjectid*)objectid { nsmanagedobjectcontext *context = [self managedobjectcontext]; // error meetings *thesamemeetings = (meetings *)[context objectwithid:objectid]; } ... @end

i'm getting error "no known class method selector 'managedobjectcontext' in next code:

nsmanagedobjectcontext *context = [self managedobjectcontext];

my objective here pass objectid of *meetings (managedobjectcontext) in firstscene secondscene can go on add together entity *meetings attributes. thanks.

that's not core info error, it's basic objective-c error. you're in method:

+ (void)setobjectid:(nsmanagedobjectid*)objectid;

the "+" says class method, not instance method. self in case secondscene class, not particular instance of class. when seek this:

nsmanagedobjectcontext *context = [self managedobjectcontext];

...you're trying phone call method named +managedobjectcontext, i.e. class method name. apparently doesn't exist, isn't surprising.

i suspect intended setobjectid: instance method, means should have - instead of + @ start of line.

ios core-data reference objectid

No comments:

Post a Comment