Re: subclassing NSArrayController
Re: subclassing NSArrayController
- Subject: Re: subclassing NSArrayController
- From: "Jonathan 'Wolf' Rentzsch" <email@hidden>
- Date: Wed, 3 Mar 2004 13:43:48 -0600
mmalcolm crawford, email@hidden, wrote:
>
Every class has a designated initialiser.
>
In the absence of other initialisation methods, it is init.
It is my understanding designated initializer is mere convention. For
example, I believe this poorly written class does *not* have a designated
initializer:
@interface NoDesignatedInitializer : NSObject {
NSString *_name;
int _age;
}
- (id)initWithName:(NSString*)aName;
- (id)initWithAge:(int)anAge;
@end
//--
@implementation NoDesignatedInitializer
- (id)initWithName:(NSString*)aName {
self = [super init];
if( self ) {
_name = [aName retain];
_age = -1;
}
return self;
}
- (id)initWithAge:(int)anAge {
self = [super init];
if( self ) {
_name = @"invalid";
_age = anAge;
}
return self;
}
@end
Yes, -initWithName and -initWithAge *should* call thru to an
-initWithNameAndAge designated initializer. But it doesn't.
Perhaps I misunderstand your definition of "designated initializer". For
example, your 'initializer' has an 's' in it for some strange reason ;-)
| Jonathan 'Wolf' Rentzsch
http://rentzsch.com
| Red Shed Software
http://redshed.net
| "better" necessarily means "different"
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.