PDA

View Full Version : self class




teguh123
Apr 14, 2011, 05:20 AM
Is this code correct


@implementation Vehicle +(id) vehicleWithColor:(NSColor*)color {
id newInstance = [[[self class] alloc] init]; // PERFECT, the class is // dynamically identified
[newInstance setColor:color]; return [newInstance autorelease];
} @end


Why use [self class]

I thought self already points to the class on static methods (the ones with +)



rudolf
Apr 14, 2011, 07:00 PM
This question belongs in one of the programming forums:
http://forums.macrumors.com/forumdisplay.php?f=142