• 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: Is "-init" really needed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is "-init" really needed?


  • Subject: Re: Is "-init" really needed?
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 7 Aug 2017 17:32:18 -0700

> On Aug 7, 2017, at 5:23 PM, Carl Hoefs <email@hidden> wrote:
>
> Is the use of +new discouraged also?

No, I use it all the time. It’s simply shorthand for [[XXX alloc] init].

These days with ARC, I tend to use +new instead of factory class methods — e.g.
[NSMutableArray new] instead of [NSMutableArray array] — on the assumption that
this avoids adding the new object to the autorelease pool. However, it’s
possible the compiler & runtime are smart enough to optimize the autorelease
out of the second call. (Greg?)

—Jens
_______________________________________________

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

References: 
 >Is "-init" really needed? (From: David Hoerl <email@hidden>)
 >Re: Is "-init" really needed? (From: Jens Alfke <email@hidden>)
 >Re: Is "-init" really needed? (From: じょいすじょん <email@hidden>)
 >Re: Is "-init" really needed? (From: Carl Hoefs <email@hidden>)

  • Prev by Date: Re: Is "-init" really needed?
  • Next by Date: Re: Is "-init" really needed?
  • Previous by thread: Re: Is "-init" really needed?
  • Next by thread: Re: Is "-init" really needed?
  • Index(es):
    • Date
    • Thread