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: Prachi Gauriar <email@hidden>
- Date: Fri, 28 May 2004 00:18:59 -0500
On May 27, 2004, at 6:21 PM, Steve Sims wrote:
+ (MyBez *)bezierPath
{
if (self = [super bezierPath])
{
[self setXLoc: 0];
[self setYLoc: 0];
}
return self;
}
Now my app works fine, but I get two compiler warning for the above
saying the following:
'MyBez' may not respond to '+setXLoc:'
'MyBez' may not respond to '+setYLoc:'
<snip>
So the question is what's the right, compiler-approved, way of doing
this kind of thing?
I would think that if your init method initializes its xLoc and yLoc to
0, you, you could just do this:
+ (MyBez *)bezierPath
{
return [[self alloc] init] autorelease];
}
I'm not sure if you should use MyBez or self as the receiver of alloc.
Perhaps others can comment on this?
If you don't implement init with the same initial values as bezierPath,
perhaps this would work:
+ (MyBez *)bezierPath
{
MyBez *path = [[self alloc] init] autorelease];
[path setXLoc:0];
[path setYLoc:0];
return path;
}
Hope that helps.
-Prachi
_______________________________________________
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.