• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Subclassing an object's creation method (NSBezierPath's +bezierPath)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Subclassing an object's creation method (NSBezierPath's +bezierPath) (From: Steve Sims <email@hidden>)

  • Prev by Date: [Moderator] Re: Spam and virii on Cocoa-dev (WAS: New changes)
  • Next by Date: Re: Code Guidelines
  • Previous by thread: Subclassing an object's creation method (NSBezierPath's +bezierPath)
  • Next by thread: Re: Subclassing an object's creation method (NSBezierPath's +bezierPath)
  • Index(es):
    • Date
    • Thread