On Mon, Jun 27, 2011 at 6:38 AM, Roland King <[email protected]> wrote:
>> The favored form for writing an init method seems to be
>>
>> -(id)init
>> {
>> if (self = [super init])
>>  {
>>  // Do something here
>>  }
>> return self;
>> }
>
> actually I think the current favoured method is
>
> -(id)init
> {
>        self = [ super init ];
>
>        if( self )
>        {
>                // your code here
>        }
>
>        return self;
> };

These are equivalent. All you did was move the self assignment out of
the if statement.

I actually prefer to use `if (!(self = [super init])) return nil;`.
Again, it is equivalent.

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to