Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

teguh123

macrumors member
Original poster
Mar 22, 2011
62
0
Is this code correct

Code:
@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 +)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.