NSNumber numberWithBool
NSNumber numberWithBool
- Subject: NSNumber numberWithBool
- From: mark hill <email@hidden>
- Date: Mon, 29 Jan 2007 06:19:17 -0800 (PST)
I have declared a NSMutableDictionary thus:
NSArray * keys = [NSArray arrayWithObjects:
@"name", @"hidden", nil];
NSArray * values = [NSArray
arrayWithObjects: @"Object Name", [NSNumber
numberWithBool:false], nil];
properties = [[NSMutableDictionary alloc]
initWithObjects: values forKeys: keys];
But cannot access the "hidden" BOOL value, it refers
to IB checkbox binding.
NSLog(@"%@", [properties valueForKeyPath: @"hidden"]);
returns 0 or 1 as expected, but I can't seem to
implement a conditional based on this!
The following does not work:
NSNumber *flag = [NSNumber numberWithBool: [properties
valueForKeyPath: @"hidden"]];
if (CFBooleanGetValue(flag)) {
// true
}
else {
// false
}
and neither does as simple:
if([flag boolValue]) {
}
Thanks for any help, and apologies if this is very obvious
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden