• 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: 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.


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

  • Prev by Date: Re: How far with accessors?
  • Next by Date: Re: Style management in NSTextView
  • Previous by thread: Re: 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