I encountered a strange problem regarding CoreData and boolean values:
In my data model I have set an entity’s property to BOOL. Later I set theEntity.theBooleanValue = [NSNumber numberWithBool:NO] and save the object. So far so good, but when I try to check for the saved property’s value with if ([theObject valueForKey:@"theBooleanValue"] == [NSNumber numberBOOL:NO]){//do something} it never jumps into the if clause. But if I check for == [NSNumber numberWithInt:0] its working… so basically I try to save a bool but it’s recognized as an int… Any ideas what’s going on there?
I encountered a strange problem regarding CoreData and boolean values: In my data model
Share
It makes more sense to examine
[[theObject valueForKey:@"theBooleanValue"] boolValue]for me. i.e.,I think
==operator compares the object pointer, and not the number itself. To compare number there is a separete method[NSNumber isEqualToNumber:].