On 15 Dec 2014, at 23:28, Jens Alfke <[email protected]> wrote: >> On Dec 15, 2014, at 2:10 PM, Kevin Bracey <[email protected]> wrote: >> >> How can I tell if the Value is a Boolean or Number in the NSDictionary? as 0 >> and 1 are valid values for a number. > > There's no clean solution for this. You have to take advantage of the fact > that the YES and NO NSNumbers are singleton objects, and do a direct pointer > comparison (with ==, *not* with isEqual:) — > > if (obj == @YES) { > it's YES > } else if (obj == @NO) { > it's NO > } else { > it's a number (possibly 0 or 1) > }
Make sure you test that thoroughly. I remember that older Mac OS X releases didn't have a separate boolean class, so depending on who writes that file on what OS, you may just get an NSNumber (even if you call NSNumber numberWithBool:). I'm not sure you can rely on actually getting a boolean object even on 10.10. I haven't tested on 10.10, but I think it still failed for me in some cases for 10.9. _______________________________________________ Cocoa-dev mailing list ([email protected]) Please 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
