• 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: Zones, [[alloc] init], and all the new + methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zones, [[alloc] init], and all the new + methods


  • Subject: Re: Zones, [[alloc] init], and all the new + methods
  • From: "John C. Randolph" <email@hidden>
  • Date: Wed, 26 Dec 2001 13:28:18 -0800

On Wednesday, December 26, 2001, at 09:06 AM, Simson Garfinkel wrote:

> I've noticed that Apple is now shying away from [[<CLASS> alloc] init]
> and has instead created a whole bunch of [<CLASS> <class>]
> constructors.
>
> For example, instead of using
>
> id dict = [[NSMutableDictionary alloc] init];
>
> to create a dictionary, the correct approach is now:
>
> id dict = [NSMutableDictionary dictionary];
>
> Similarly, instead of
>
> id path = [[NSBezierPath alloc] init]

Actually, this is correct, too.

>
> We are now to use:
>
> id path = [NSBezierPath bezierPath];
>
> Can anyone share with me the logic for this?

The alloc-init sequence is still there, and it won't be going
away. The convenience constructors you mention return
autoreleased instances, so you can use them without bothering
with -release messages.

> One of the big advantage of the [[<class> alloc] init] approach
> is that it very easily became [[<class> allocFromZone:myZone] init]

And that advantage is still there..

-jcr

"Computers in the future may weigh no more than 1.5 tons." -
Popular Mechanics, 1949


References: 
 >Zones, [[alloc] init], and all the new + methods (From: "Simson Garfinkel" <email@hidden>)

  • Prev by Date: no title bar, no tool tips
  • Next by Date: Newbie question about file compression
  • Previous by thread: Re: Zones, [[alloc] init], and all the new + methods
  • Next by thread: NSFont and the Carbon Font Manager
  • Index(es):
    • Date
    • Thread