ios - Core Data unrecognized selector error -
ios - Core Data unrecognized selector error -
i using core info save strings. have next class called results
results.h
#import <coredata/coredata.h> @interface results : nsmanagedobject @property(nonatomic, retain) nsstring *lessondate; @property(nonatomic, retain) nsstring *lesson; @property(nonatomic, retain) nsstring *location; @property(nonatomic, retain) nsstring *start; @property(nonatomic, retain) nsstring *end; @end
results.m
#import "results.h" @implementation results @dynamic lessondate; @dynamic lesson; @dynamic location; @dynamic start; @dynamic end; @end
the next code perform save:
-(void)savelesson{ results *result = (results *)[nsentitydescription insertnewobjectforentityforname:@"diary" inmanagedobjectcontext:managedobjectcontext]; result.lessondate = calendardatestring; result.lesson = [nsstring stringwithformat:@"%@", lessontext.text]; result.location = [nsstring stringwithformat:@"%@", locationtest.text]; result.start = [nsstring stringwithformat:@"%@", starttimetext.text]; result.end = [nsstring stringwithformat:@"%@", endtimetext.text]; nserror *error; // here's actual save happens, , if doesn't print out console if (![managedobjectcontext save:&error]) { nslog(@"problem saving: %@", [error localizeddescription]); } [self dismissviewcontrolleranimated:yes completion:nil];
}
but when seek save info in app, app crashed , shows these errors
2013-02-18 11:46:25.705 after managedobjectcontext: <nsmanagedobjectcontext: 0x1f892480> 2013-02-18 11:46:33.762 -[nsmanagedobject setlesson:]: unrecognized selector sent instance 0x1f80b380 2013-02-18 11:46:33.764 *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[nsmanagedobject setlesson:]: unrecognized selector sent instance 0x1f80b380'
can please tell me why crashing? exact same code in app , works fine.
you creating entity different expect.
you calling
[nsentitydescription insertnewobjectforentityforname:@"diary" inmanagedobjectcontext:managedobjectcontext];
which creates entity diary
. set @"results"
first argument method.
while assigning created diary
entity results
object, syntactic sugar—the real object underneath have passed entity name. diary
object doesn't have lesson
property, , exception.
ios core-data nsmanagedobject
Comments
Post a Comment