To all who replied, thank you. This is awesome.
Thanks for outlining the difference between the two. Now I know and can ignore
it. But if I didn't, I'd always be wondering.
This certainly puts my mind at ease. Well, at least with regards to [NSArray
new]. Other issues shall remain uneased
The class method new is the same as alloc/init although by implementation, it
may be faster if the class doesn't need to pass a placeholder object from
alloc—some classes do that. The class method array is much like
alloc/init/autorelease in the MRC days although it may coalesce things, but
+new is alloc/init. +array is alloc/init/autorelease. Should be equivalent.
> On Aug 16, 2016, at 7:42 AM, Alex Zavatone 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,
> On Aug 16, 2016, at 9:42 AM, Alex Zavatone 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
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
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