Re: Subclassing an object's creation method (NSBezierPath's +bezierPath)
Re: Subclassing an object's creation method (NSBezierPath's +bezierPath)
- Subject: Re: Subclassing an object's creation method (NSBezierPath's +bezierPath)
- From: Peter Maurer <email@hidden>
- Date: Fri, 28 May 2004 10:47:17 +0200
+ (MyBez *)bezierPath
{
if (self = [super bezierPath])
{
[self setXLoc: 0];
[self setYLoc: 0];
}
return self;
}
Background information: You shouldn't use "self" here, because in class
methods such as yours, "self" refers to the class, not an instance.
Prachi's suggestion...
+ (MyBez *)bezierPath
{
MyBez *path = [[self alloc] init] autorelease];
[path setXLoc:0]; // only if you didn't do this in your init method
[path setYLoc:0]; // only if you didn't do this in your init method
return path;
}
... is the correct (and more elegant) way of doing this, IMHO. Cheers,
Peter.
_______________________________________________
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.