Women in Technology

Hear us Roar



Article:
  The Cocoa Controller Layer
Subject:   Override add?
Date:   2004-08-01 00:32:42
From:   donarb
Response to: Override add?

Creating a special subclass just to set an object's attributes is way too much work. You'd be better off just putting the code that assigns the default names into the Book class itself, using the init() method. Somewhere down the road you'll be banging your head against the wall trying to figure out where the default name is being set. Put this into the Book object instead:



- (id)init
{
self = [super init];
if (self != nil) {
[self setTitle:@"Unknown Title"];
[self setAuthor:@"Unknown Author"];
}
return self;
}