Returns a new instance of the receiving class.
SDKs
- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Objective-C
Declaration
+ (instancetype)alloc;
Return Value
A new instance of the receiver.
Discussion
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 alloc] init];
Do not override alloc
to include initialization code. Instead, implement class-specific versions of init...
methods.
For historical reasons, alloc
invokes alloc
.