Search code examples
objective-cnsarray

What is the Implementation of: + (instancetype)array;


I'm curious to know what the actual implementation of the class method + (instancetype)array that is declared in NSArray.h would look like:

NSArray.h

+ (instancetype)array;

NSArray.m

+ (instancetype)array {
    // What goes here?
}

Solution

  • Most likely:

    + (instancetype)array {
        return [[self alloc] init];
    }
    

    But it's possible it may do other things, or call other initializers.

    I'm not sure if it does anything special because it's a toll-free bridged class.