• 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
Re: BOOL parameter passed as nil object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BOOL parameter passed as nil object


  • Subject: Re: BOOL parameter passed as nil object
  • From: Scott Ribe <email@hidden>
  • Date: Tue, 19 Apr 2016 17:14:20 -0600

On Apr 19, 2016, at 2:20 PM, Alex Zavatone <email@hidden> wrote:
>
> Considering its use at the language level, would values of nil and 0 result as NO and every other value of 1 or > == YES?

No, when it's a char, there are 254 values which are not == to either NO or YES. This can be a pretty severe trap for the unaware. (Especially the part where multiples of 256 can become == NO...)

When it's a proper C99'ish bool, then all values are cast to bool at assignment, and so it is always == either 0 or 1.


--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice






_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


References: 
 >BOOL parameter passed as nil object (From: Carl Hoefs <email@hidden>)
 >Re: BOOL parameter passed as nil object (From: Alex Zavatone <email@hidden>)
 >Re: BOOL parameter passed as nil object (From: Jens Alfke <email@hidden>)
 >Re: BOOL parameter passed as nil object (From: Greg Parker <email@hidden>)
 >Re: BOOL parameter passed as nil object (From: Alex Zavatone <email@hidden>)

  • Prev by Date: No Alert, Discard Change, & Beep
  • Next by Date: Re: No Alert, Discard Change, & Beep
  • Previous by thread: Re: BOOL parameter passed as nil object
  • Next by thread: Re: BOOL parameter passed as nil object
  • Index(es):
    • Date
    • Thread