alloc, init, and new in Objective-C [duplicate]

+new is implemented quite literally as:

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

Nothing more, nothing less. Classes might override it, but that is highly atypical in favor of doing something like +fooWithBar:.


Originally in Objective-C, objects were created with new. As the OpenStep/Cocoa framework evolved, the designers developed the opinion that allocating the memory for an object and initializing its attributes were separate concerns and thus should be separate methods (for example, an object might be allocated in a specific memory zone). So the alloc-init style of object creation came into favor.

Basically, new is old and almost-but-not-quite deprecated — thus you'll see that Cocoa classes have a lot of init methods but almost never any custom new methods.