Re: [Obj-C] if (self) vs. if (self != nil)
Re: [Obj-C] if (self) vs. if (self != nil)
- Subject: Re: [Obj-C] if (self) vs. if (self != nil)
- From: William Squires <email@hidden>
- Date: Sun, 26 Feb 2012 20:02:11 -0600
Actually, I believe there's a specific build setting that special cases just this construct; it seems to default to 'on' at least in Xcode 4.2 under SL, as I never get the 'unintended assignment' warning, even though it does warn me in other cases where I might type "if (a = b)" or some such. IIRC, it's near the bottom of the compiler warnings that you can check off, but it's getting late at night...
On Feb 26, 2012, at 7:40 PM, Graham Cox wrote:
>
> On 27/02/2012, at 12:13 PM, William Squires wrote:
>
>> I prefer the "if (self = [super init])" combined form, myself.
>
>
> One potentially annoying thing about this form is that, if you compile with plenty of warnings on, such as the possible unintended assignment warning (if not, why not?) then this flags a warning.
>
> Apple recommend:
>
> self = [super init];
> if( self )
> {
> ...
> }
>
>
> Anyway, this seems to be one of those tiny trivial issues that people seem to get very religious about. It takes a second to type in any form, so what's the big deal?
>
> --Graham
>
>
_______________________________________________
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