when I try to set the variable eventId of my NSManagedObject (Event) I get ther error EXC_BAD_ACCESS.
I don't know the reason.
Here's the code of my class 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"];
}
...
Anyone can solve the problem?
Thanks for help
If you look closely at the documentation, you'll see that the primitive accessor methods for the scalar attribute double length in the example still use NSNumber * arguments and return values:
@interface MyManagedObject (PrimitiveAccessors)
@property (nonatomic, retain) NSNumber *primitiveLength;
@end
[Note: I added the * that was missing in the original code snippet in Apple's documentation.]
So try declaring your primitive accessors with NSNumber * arguments and return values.
Or if you really must, consider implementing your own primitive accessor methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With