Subclassing
Subclassing
- Subject: Subclassing
- From: Sam Goldman <email@hidden>
- Date: Sat, 13 Oct 2001 01:51:07 -0700
OK, I am trying to conquer the concept of subclassing. Some of it I
understand, but then when I tried to apply what I know, nothing happened.
Basically what I did was subclass a NSButton and a NSButtonCell. I created
the source files and then connected the headers. Then I made the NSButton
use the NSButtonCell with this code:
+ (Class) cellClass
{
return [MyButtonCell class];
}
I didn't implement anything in the NSButtonCell class (MyButtonCell) so I
didn't expect anything to happen. Then, after implementing these methods:
- (NSCellImagePosition)imagePosition
{
return NSImageLeft;
}
- (NSImage *)image
{
return [NSImage imageNamed:@"StartPage"];
}
And ran the program, no image showed. Keep in mind that I am totally new to
this, so if it's a totally obvious thing, don't be too mean. Also, it seemed
to me like a lot of the methods would have to be called by a Controller
object. If that's the case (which I don't think it is), what's the point of
subclassing?
- Sam