Re: Best practice question
Re: Best practice question
- Subject: Re: Best practice question
- From: Glen Simmons <email@hidden>
- Date: Fri, 27 Oct 2006 15:54:12 -0500
On Oct 27, 2006, at 3:46 PM, Alan Smith wrote:
Hi all,
I've seen many variations of the init method and I'm wondering which
is the best way to go. Currently I do it like this;
- (id)init
{
if (self = [super init])
{
// Perform init code
return self;
}
return nil;
}
Many thanks, Alan
I don't care for multiple return statements, and in your code, the
second one is redundant anyway, so I'd do it like this:
- (id)init
{
self = [super init]; // Putting this here avoids a warning about
unintentional assignment in the if below
if (self)
{
// Do stuff
}
return self; // Only need one return b/c we're testing for nil in
the if above
}
(typed in Mail, blah blah)
HTH,
Glen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden