Re: Danger: @true and @false aren't considered booleans
Re: Danger: @true and @false aren't considered booleans
- Subject: Re: Danger: @true and @false aren't considered booleans
- From: Alexander von Below <email@hidden>
- Date: Mon, 20 Aug 2012 00:12:12 +0200
Am 19.08.2012 um 23:59 schrieb Jens Alfke <email@hidden>:
>> Note: it's not sufficient to check whether a NSNumber instance is a boolean by comparing the *pointer* against kCFBooleanTrue respectively kCFBooleanFalse.
>
> Nevertheless, this appears to be what JSNSONSerialization does:
> [NSNumber numberWithChar: 1] —> "1"
> [NSNumber numberWithBOOL: YES] —> "true"
> even though there is no difference I can tell between the two NSNumber instances (both have encoding "c" and value 1.)
I am not sure if I am answering the question, but the safest way I know of to check if the NSNumber object is an CFBooleanRef is this:
CFGetTypeID(numberObject) == CFBooleanGetTypeID()
(and as you said, it is hard to imagine that being something else than kCFBooleanTrue or kCFBooleanFalse
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden