Re: Is "-init" really needed?
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