Type Method 型メソッド

alloc

Returns a new instance of the receiving class. レシーバのクラスの新しいインスタンスを返します。

Declaration 宣言

+ (instancetype)alloc;

Return Value 戻り値

A new instance of the receiver. レシーバ(受取り手)の新しいインスタンス。

Discussion 解説

This is an instance variable of the new instance that is initialized to a data structure describing 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 allocWithZone:.

See Also 参照

Creating, Copying, and Deallocating Objects オブジェクトの作成、複製、そして割り当て解除