You can't tell 'self' to be allocated. Try this instead:

+ (MyObject *)myObject
  {
     return [[[MyObject alloc] init] autorelease];
  }


On Jul 5, 2009, at 10:40 AM, DKJ wrote:

I'm trying to write one of those convenient class initialisers for one of my objects. On my still-incomplete understanding of these matters, this is what I need to have:

Header:

  + (MyObject *)myObject;

Implementation:

  + (MyObject *)myObject
  {
     return [[[self alloc] init] autorelease];
  }

(I'd have the usual init method in here as well, of course.)

Have I done this correctly? (My programme is crashing, but there are plenty of other mistakes I may have made.)

I've been looking in the docs for an explicit example of this kind of initialiser, but haven't found one yet.

dkj
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/dimitri008%40mac.com

This email sent to dimitri...@mac.com

--
定魅刀利
Dimitri Bouniol
dimitri...@mac.com
http://www.appkainime.com/

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to