Type Method


Returns a new instance of the receiving class.


+ (instancetype)allocWithZone:(struct _NSZone *)zone;



This parameter is ignored.

Return Value

A new instance of the receiver.


The isa instance variable of the new instance is initialized to a data structure that describes the class; memory for all other instance variables is set to 0.

You must use an init... method to complete the initialization process. For example:

TheClass *newObject = [[TheClass allocWithZone:nil] init];

Do not override allocWithZone: to include any initialization code. Instead, class-specific versions of init... methods.

This method exists for historical reasons; memory zones are no longer used by Objective-C.

See Also

Creating, Copying, and Deallocating Objects

+ alloc

Returns a new instance of the receiving class.

- init

Implemented by subclasses to initialize a new object (the receiver) immediately after memory for it has been allocated.

- copy

Returns the object returned by copyWithZone:.

+ copyWithZone:

Returns the receiver.

- mutableCopy

Returns the object returned by mutableCopyWithZone: where the zone is nil.

+ mutableCopyWithZone:

Returns the receiver.

- dealloc

Deallocates the memory occupied by the receiver.

+ new

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software