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: Roland King <email@hidden>
- Date: Sun, 19 Aug 2012 11:43:30 +0800
Interesting. I think I read a discussion about something similar and seem to recall that @YES and @NO do return kCFBooleanTrue and kCFBooleanFalse. Not to suggest for one second that @true and @false shouldn't do the what you suggest, did you try @YES and @NO at all?
On 19 Aug, 2012, at 11:33 AM, Jens Alfke <email@hidden> wrote:
> Warning to people 'modernizing' their syntax to use the new Obj-C literals: I've run into a serious problem with @true and @false. The runtime objects these create are _not_ the same as those created by [NSNumber numberWithBool] or the CF constants kCFBooleanTrue and kCFBooleanFalse. They're created with the type-encoding "i" (integer) instead of "c" (char).
>
> The most serious problem — and the one that caused me to discover this — comes with NSJSONSerialization. @true and @false don't encode to JSON as "true" and "false", but "0" and "1". This can really screw up things that try to parse the JSON your code generates. In my case, some well-tested CouchDB client code started to fail after I modernized the syntax, and I traced the problem down to this. Apparently CouchDB was unhappy about some boolean parameter values being "1" instead of "true" and returned an HTTP 500 status.
>
> I've filed a bug report against Clang, which has the distinct advantage that you can actually read my bug report (imagine that!) and see my test case.
> http://llvm.org/bugs/show_bug.cgi?id=13640
>
> —Jens
> _______________________________________________
> 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
_______________________________________________
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