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. - ARC 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 surrounding code. Just my 2 cents, and I may be completely wrong. Gerd > On Aug 8, 2017, at 05:13, Uli Kusterer <witness.of.teacht...@gmx.net> wrote: > > On 8. Aug 2017, at 02:23, Carl Hoefs <newsli...@autonomy.caltech.edu> 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 formally deprecated, and I'm seeing > it used more and more in ARC code these days. > > Cheers, > -- Uli Kusterer > "The Witnesses of TeachText are everywhere..." > http://www.zathras.de > > _______________________________________________ > > Cocoa-dev mailing list (Cocoaemail@example.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/gerti-cocoadev%40bitart.com > > This email sent to gerti-cocoa...@bitart.com _______________________________________________ Cocoa-dev mailing list (Cocoafirstname.lastname@example.org) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com