• 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: Convenience methods and classes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convenience methods and classes


  • Subject: Re: Convenience methods and classes
  • From: Ondra Cada <email@hidden>
  • Date: Thu, 31 Jan 2002 22:13:27 +0100

Drew,

>>>>>> Drew McCormack (DMC) wrote at Thu, 31 Jan 2002 20:02:55 +0100:
DMC> I want to write a convenience constructor, but can't figure out how I
DMC> can access the Class instance from within the class method. For example,
DMC> if I want to write a method "+expression" which allocates and
DMC> initializes an "Expression", how do I allocate the expression in the
DMC> method? Can I just do this
DMC> [self alloc]
DMC>
DMC> Probably not.

Yep, that's the way. Why not?

The generic pattern of (almost) all convenience constructors is pretty simple:

+(SomeClass)someClassWithBlah:foo blah:bar ... {
return [[[self alloc] initWithBlah:foo blah:bar ...] autorelease];
}

Quite seldom you need more.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.cz
private email@hidden http://www.ocs.cz/oc


References: 
 >Convenience methods and classes (From: Drew McCormack <email@hidden>)

  • Prev by Date: Re: System contextual menus
  • Next by Date: Re: <no subject>
  • Previous by thread: Re: Convenience methods and classes
  • Next by thread: The best lookup/hash model?
  • Index(es):
    • Date
    • Thread