• 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: Resend: array = [NSArray new] or array = [NSArray array]?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resend: array = [NSArray new] or array = [NSArray array]?


  • Subject: Re: Resend: array = [NSArray new] or array = [NSArray array]?
  • From: Ryan Dignard <email@hidden>
  • Date: Fri, 19 Aug 2016 10:49:59 -0700

Under ARC there should be no appreciable difference.  People who prefer
+new will generally point out it's a keyword or operator in other languages
so its meaning is not ambiguous.

With manual reference counting, the difference is that +array is
autorelease where as with +new your code is responsible for releasing the
object.  Some projects used to discourage the use of +new as it was one
less selector/function name to memorize (i.e. copy, alloc, create..., new).

On Tue, Aug 16, 2016 at 7:42 AM, Alex Zavatone <email@hidden> wrote:

> I sent this out this morning but it got eaten, so this is a resend.  Sorry
> if it gets to some of you twice.
>
>
>
> Yes, I know about literals, but I have a different question here.
>
>
> Is this safe?
>
> I have seen this in some code in our codebase:
> array = [NSArray new];
>
> I'm familiar with using the public method from the NSArray header and what
> the docs say to use:
> or array = [NSArray array];
>
> Is there any risk to using [NSArray new] to init an array instead of
> [NSArray array]??
>
> I'm surprised to see this being used in our codebase and would like to
> make sure we are not destroying the universe by using it.
>
> Thank you in advance.
> - Alex Zavatone
>
>
> _______________________________________________
>
> 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:
> email@hidden
>
> This email sent to email@hidden
_______________________________________________

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: 
 >Class is implemented in both (From: Trygve Inda <email@hidden>)
 >Re: Class is implemented in both (From: Stephane Sudre <email@hidden>)
 >Re: Class is implemented in both (From: Stephane Sudre <email@hidden>)
 >Resend: array = [NSArray new] or array = [NSArray array]? (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: array = [NSArray new] or array = [NSArray array]?
  • Next by Date: Re: array = [NSArray new] or array = [NSArray array]?
  • Previous by thread: Resend: array = [NSArray new] or array = [NSArray array]?
  • Next by thread: Re: Resend: array = [NSArray new] or array = [NSArray array]?
  • Index(es):
    • Date
    • Thread