Re: Getting class when instantiating a singleton

Steve Christensen

On Aug 30, 2017, at 2:44 PM, Alex Zavatone <zav@...> wrote:

On Aug 30, 2017, at 4:40 PM, Steve Christensen <punster@...> wrote:

That's "instance = [self new];", right? :)


I’m trying this out to see if this is valid.  

From the headers for NSObject.h;
+ (instancetype)new OBJC_SWIFT_UNAVAILABLE("use object initializers instead");

Sure, why not, at least for Obj-C? The method description says, "Allocates a new instance of the receiving class, sends it an init message, and returns the initialized object."

And I checked out at <> and the method implementation looks like this...

+ (id)new {
    return [[self alloc] init];

...which sure looks a lot like the description.

Join to automatically receive all group messages.