当我尝试设置我的变量eventId
时,我NSManagedObject (Event)
得到了错误EXC_BAD_ACCESS
。我不知道原因。
这是我班级的代码Event
@interface Event : NSManagedObject
@property (assign) NSInteger eventId;
@end
@interface Event (PrimitiveAccessors)
- (NSInteger)primitiveEventId;
- (void)setPrimitiveEventId:(NSInteger)event_id;
@end
@implementation Event
@dynamic eventId;
...
-(NSInteger)eventId
{
[self willAccessValueForKey:@"eventId"];
NSInteger id = [self eventId];
[self didAccessValueForKey:@"eventId"];
return id;
}
-(void)setEventId:(NSInteger)event_id
{
[self willChangeValueForKey:@"eventId"];
[self setPrimitiveEventId:event_id]; //Here I get the error
[self didChangeValueForKey:@"eventId"];
}
...
任何人都可以解决问题?
感谢帮助