I have an entity in my database called “Me” and it has a BOOL attribute called “loggedIn”. I set the default value for the attribute to NO like so:

Just to make sure it’s set to NO, I also set it programmatically but it still is shows up YES in the log:
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Me"];
NSError *err;
NSUInteger count = [context countForFetchRequest:request error:&err];
if (count == 0) {
NSManagedObject *me = [NSEntityDescription insertNewObjectForEntityForName:@"Me" inManagedObjectContext:context];
}
NSArray *fetchedObjects = [context executeFetchRequest:request error:&err];
[[fetchedObjects objectAtIndex:0] setValue:[NSNumber numberWithBool:NO] forKey:@"loggedIn"];
NSString *amIYesOrNo = [NSString stringWithFormat:@"%@", ([[fetchedObjects objectAtIndex:0] valueForKey:@"loggedIn"] ? @"YES" : @"NO")];
NSLog(amIYesOrNo);
amIYesOrNo always shows up YES when it’s supposed to be NO. What is going on?
valueForKey:@”loggedIn” is returning a valid object to you and then your ?: operator is checking whether it’s non-nil and it always is. You need to apply a boolValue method call to the NSNumber to get what it contains.