• 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: Alastair Houghton <email@hidden>
  • Date: Thu, 10 Aug 2017 14:59:42 +0100

On 10 Aug 2017, at 14:57, email@hidden wrote:
>
> On Aug 10, 2017, at 02:18, Alastair Houghton <email@hidden>
> wrote:
>>
>> Personally I *would* still discourage +new in favour of class-specific
>> convenience constructors because I think it’s less expressive and also less
>> consistent (e.g. +array is better, in my opinion, than +new, not least
>> because +arrayWithObjects: and others exist).
>
> [NSArray new] := [[NSArray alloc]init]
>
> [NSArray array] := [[[NSArray alloc]init]autorelease]
>
> +array and friends came along with the introduction of autorelease pools, to
> replace +new with something that didn't imply ownership (the oft mentioned
> special meaning of "new" as prefix). So while with ARC they are essentially
> equivalent, previously they were not.

Yes, I know that, thanks.

The point is, with ARC, they’re equivalent, and most new code uses ARC, so,
again, I’d discourage +new in favour of class-specific convenience constructors.

Kind regards,

Alastair.

--
http://alastairs-place.net

_______________________________________________

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: Is "-init" really needed?
      • From: Charles Srstka <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>)
 >Re: Is "-init" really needed? (From: Uli Kusterer <email@hidden>)
 >Re: Is "-init" really needed? (From: email@hidden)
 >Re: Is "-init" really needed? (From: Doug Hill <email@hidden>)
 >Re: Is "-init" really needed? (From: Alastair Houghton <email@hidden>)
 >Re: Is "-init" really needed? (From: Doug Hill <email@hidden>)
 >Re: Is "-init" really needed? (From: Alastair Houghton <email@hidden>)
 >Re: Is "-init" really needed? (From: 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