Re: Getting class when instantiating a singleton


Alex Zavatone
 


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

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

Yes.  

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");

From the Quick Help ins[pector panel.

+ (instancetype)new;
Description

Allocates a new instance of the receiving class, sends it an initmessage, and returns the initialized object.

This method is a combination of alloc and init. Like alloc, it initializes the isa instance variable of the new object so it points to the class data structure. It then invokes the init method to complete the initialization process.
Returns
A new instance of the receiver.
AvailabilityiOS (2.0 and later), macOS (10.0 and later), tvOS (9.0 and later), watchOS (2.0 and later)
Declared InObjective-C
MoreType Method Reference


Join cocoa@apple-dev.groups.io to automatically receive all group messages.