|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On 7 Oct 2009, at 22:58, Dave Keck wrote:
... eek! On the other hand, this is exactly the kind of code I like:
- (id)init { if (!(self = [super init])) return nil;
myIvar = [[NSString alloc] init];
if (!myIvar) goto failed;
myOtherIvar = [[NSArray alloc] init];
if (!myOtherIvar) goto failed;
myThirdIvar = [[NSDictionary alloc] init];
if (!myThirdIvar) goto failed;
return self;
failed: { [self release]; return nil; } }
... and no need to squint - that's a goto. Who wants to rumble?
Probably better to write
- (id)init
{
if (!(self = [super init]))
return nil; myIvar = [[NSString alloc] init];
myOtherIvar = [[NSArray alloc] init];
myThirdIvar = [[NSDictionary alloc] init]; if (!myIvar || !myOtherIvar || !myThirdIvar) {
[self release];
return nil;
}return self; }
Kind regards,
Alastair.
-- http://alastairs-place.net
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
| References: | |
| >Fwd: Constructive Criticism (From: Mick Walker <email@hidden>) | |
| >Re: Constructive Criticism (From: Benjamin Dobson <email@hidden>) | |
| >Re: Constructive Criticism (From: Gerard Iglesias <email@hidden>) | |
| >Re: Constructive Criticism (From: Dave Keck <email@hidden>) | |
| >Re: Constructive Criticism (From: Jeremy Pereira <email@hidden>) | |
| >Re: Constructive Criticism (From: Dave Keck <email@hidden>) |
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.