• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Danger: @true and @false aren't considered booleans
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Danger: @true and @false aren't considered booleans


  • Subject: Danger: @true and @false aren't considered booleans
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 18 Aug 2012 20:33:54 -0700

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


  • Follow-Ups:
    • Re: Danger: @true and @false aren't considered booleans
      • From: Andreas Grosam <email@hidden>
    • Re: Danger: @true and @false aren't considered booleans
      • From: Roland King <email@hidden>
  • Prev by Date: Re: Deprecated warnings on Intel 10.4.11, not on PPC 10.4.11
  • Next by Date: Re: Danger: @true and @false aren't considered booleans
  • Previous by thread: Re: @loader_path only works in Xcode
  • Next by thread: Re: Danger: @true and @false aren't considered booleans
  • Index(es):
    • Date
    • Thread