• 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
Convenience initialisers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Convenience initialisers


  • Subject: Convenience initialisers
  • From: DKJ <email@hidden>
  • Date: Sun, 5 Jul 2009 10:40:05 -0700

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


  • Follow-Ups:
    • Re: Convenience initialisers
      • From: Andy Lee <email@hidden>
    • Re: Convenience initialisers
      • From: Ken Thomases <email@hidden>
    • Re: Convenience initialisers
      • From: Dimitri Bouniol <email@hidden>
  • Prev by Date: Re: Yet another memory management question
  • Next by Date: Re: Convenience initialisers
  • Previous by thread: Re: Wrap to Page method
  • Next by thread: Re: Convenience initialisers
  • Index(es):
    • Date
    • Thread