Re: Convenience initialisers
Re: Convenience initialisers
- Subject: Re: Convenience initialisers
- From: Dimitri Bouniol <email@hidden>
- Date: Sun, 05 Jul 2009 10:47:27 -0700
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 (email@hidden)
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:
This email sent to email@hidden
--
定魅刀利
Dimitri Bouniol
email@hidden
http://www.appkainime.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden