in an NSViewController subclass this BOOL returns "fault is (null)" in the console:
Submission *sub = [self representedObject];
BOOL fault = [sub isFault];
NSLog(@"fault is : %@", fault);
i do have the sub managedObject's properties, so i know that its available. testing with committedValuesForKeys (right below the above开发者_运维百科 in the same method) gives me the expected property values in the console.
NSLog(@"[sub committedValuesForKeys:nil] is : %@", [sub committedValuesForKeys:nil]);
self here is an NSCollectionViewItem, a subclass of NSViewController.
There are some other cleaner ways to do this:
BOOL fault = YES;
NSLog(fault ? @"Yes" : @"No");
and
BOOL fault = YES;
NSLog(@"Bool fault: %d",fault);
via How to print Boolean flag in NSLog?
You can't check the BOOLs value like that. Instead do:
if (fault) {
NSLog(@"Fault is true");
} else {
NSLog(@"Fault is false");
}
精彩评论