alloc

Declaration

+ (id)alloc

Description 

Returns a new instance of the receiving class.
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 allocWithZone:.

適用されたクラスの新しいインスタンスを返す。
新しく作られたインスタンスのisaインスタンス変数はそのクラスを表すデータ構造によって初期化され、他のすべてのインスタンス変数のメモリーは0に設定される。
初期化プロセスを完了するには init... メソッドを用いなければならない。例えば、
TheClass *newObject = [[TheClass alloc] init];
allocを初期化コードを含む様にオーバーライドしてはいけない。代わりにクラスごとのinit...メソッドを用いることができる。
歴史的理由により、allocはallocWithZoneを呼び出す。

Returns 

A new instance of the receiver.

Availability

iOS (2.0 and later)

Declared 

NSObject.h

Reference 

NSObject Class Reference

Related 

allocWithZone:,copy,copyWithZone:,dealloc,init,mutableCopy,mutableCopyWithZone:,new

Samples 

CoreTextPageViewer,MVCNetworking,TableViewSuiteUICatalog,iPhoneCoreDataRecipes

コメント