Posts Tagged core data

How to insert BOOL (boolean) value into ManagedObject in Core Data – iOS, iPad, iPhone

If you want to insert BOOL type into core data, you can do it with NSNumber’s member method +numberWithBool:

BOOL myBool = YES;
NSNumber *boolAsNumber = [NSNumber numberWithBool:myBool];
//now you can pass boolAsNumber into you managed object for storage!

If you want to retrieve a BOOL from NSNumber you can use -boolValue.

NSNumber *boolAsNumber = [NSNumber numberWithBool:NO];

BOOL getBool = [boolAsNumber boolValue];

, , , ,

Leave a comment