From my understanding of Core Data, all that is necessary for primitive accessors to work is the @dynamic directive for the property name (as well as declaring primitive accessors for that property within the entity implementation).
For some reason, when using the generated primitive accessor the setState: method is not modifying the state property:
- (int)state
{
NSNumber * tmpValue;
[self willAccessValueForKey:@"state"];
tmpValue = [self primitiveState];
[self didAccessValueForKey:@"state"];
return [tmpValue intValue];
}
- (void)setState:(int)value
{
[self willChangeValueForKey:@"state"];
[self setPrimitiveState:[NSNumber numberWithInt:value]];
[self didChangeValueForKey:@"state"];
}
while using the key-value-coding version does modify the state property
- (int)state
{
NSNumber * tmpValue;
[self willAccessValueForKey:@"state"];
tmpValue = [self primitiveValueForKey:@"state"];
[self didAccessValueForKey:@"state"];
return [tmpValue intValue];
}
- (void)setState:(int)value
{
[self willChangeValueForKey:@"state"];
[self setPrimitiveValue:[NSNumber numberWithInt:value] forKey:@"state"];
[self didChangeValueForKey:@"state"];
}
in both cases, I primitive accessors are declared as follows (and as per Apple's example and code generation):
@interface Post (CoreDataGeneratedPrimitiveAccessors)
- (NSNumber *)primitiveState;
- (void)setPrimitiveState:(NSNumber *)value;
@end
I'm a bit at a loss to why this would be. Any help would be greatly appreciated!