• 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: [Obj-C] if (self) vs. if (self != nil)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Obj-C] if (self) vs. if (self != nil)


  • Subject: Re: [Obj-C] if (self) vs. if (self != nil)
  • From: David Mirabito <email@hidden>
  • Date: Sat, 25 Feb 2012 09:29:49 +0000

Not terribly helpful since the cocoa headers are what they are, but in other codebases I sneak around issue this by setting up the defines:

#define FALSE 0
#define TRUE (!FALSE)

Then something like "if (mybool == TRUE)" acts as expected across all non-zero values.

Also, IIRC, static analysis tools can enforce all boolean expressions in your code is a bolean logical operator or resolves to a 'typedef int mybool_t', but I'm less than convinced of the usefulness of this.

-DavidM


On 24/02/2012, at 8:36 PM, Sean McBride wrote:

> On Fri, 24 Feb 2012 10:36:51 -0700, Keary Suska said:
>
>> I don't believe this is the case. There can be funny issues with BOOL
>> types, such that BOOL == YES is an inadvisable construct, since your
>> BOOL could be an integer of any value.
>
> Indeed, and it's extremely frustrating.  I encourage you to file bugs on this, or maybe add a comment here:
>
> <http://llvm.org/bugs/show_bug.cgi?id=9194>
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng                 email@hidden
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada
>
>
>
> _______________________________________________
>
> 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


_______________________________________________

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


  • Follow-Ups:
    • Re: [Obj-C] if (self) vs. if (self != nil)
      • From: Scott Ribe <email@hidden>
References: 
 >[Obj-C] if (self) vs. if (self != nil) (From: Oleg Krupnov <email@hidden>)
 >Re: [Obj-C] if (self) vs. if (self != nil) (From: Keary Suska <email@hidden>)
 >Re: [Obj-C] if (self) vs. if (self != nil) (From: Sean McBride <email@hidden>)

  • Prev by Date: Re: [Obj-C] if (self) vs. if (self != nil)
  • Next by Date: Re: NSFileWrapper Role
  • Previous by thread: Re: [Obj-C] if (self) vs. if (self != nil)
  • Next by thread: Re: [Obj-C] if (self) vs. if (self != nil)
  • Index(es):
    • Date
    • Thread