开发者

If an NSManagedObject subclassed object is an NSViewController's representedObject is it a fault?

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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜