Subject: Re: Is "-init" really needed?
Unlike with Swift, in Objective-C it is to no small part the developers who
drive how the language evolves.
+new used to be the canonical initializer in the very olden days. But then
folks wanted a better distinction between object allocation and object
initialization to make memory management a bit more mechanical and less hidden.
They also came up with the concept of the "designated initializer". That was in
the very early 80s IIRC.
This worked, but two things happened:
- having to remember designated initializers, and chaining them correctly when
subclassing, is a tad cumbersome. It's like having to know a secret handshake
to use an object. Further Objective-C never formally introduced syntactic
support for a designated initializer, so eventually some people resorted to
some weird hinting with macros. Yuk.
So "designated initializers" became de-emphasized over time, most modern
objects rarely use them. And ARC now makes it less important to distinguish
between object allocation and object initialization. Hence the renaissance of
+new. And with the advent of dot notation some (like me) even started to
further de-emphasize that by using "MyClass.new". This is debatable I guess,
but I like it, because it visually distracts less from the purpose of the
Just my 2 cents, and I may be completely wrong.
> On Aug 8, 2017, at 05:13, Uli Kusterer <[email protected]> wrote:
> On 8. Aug 2017, at 02:23, Carl Hoefs <[email protected]> wrote:
>> Is the use of +new discouraged also?
> Apple have gone back and forth on this AFAIR. +new was actually the
> pre-retain/release way to create an object. So it has been discouraged since
> ... OpenStep, I think? But it was never for...
mally deprecated, and I'm seeing
> it used more and more in ARC code these days.
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> Cocoa-dev mailing list ([email protected])
> 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 protected]
Cocoa-dev mailing list ([email protected]
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 protected]