开发者

Class objects and instance of a class

My question is : what is the 开发者_如何学运维difference between a class object and an anstance of that class. we know that every class in objective c is an object.

thanks for your answers,


Basically, a class object is also an instance of another class. This another class (called a metaclass) has internal data and methods that are completely different from the original class, and most of them are intended to help you do tasks related to the instances of the original class.

Although technically not correct, you could think of a class object as a global object that is automatically instantiated for you. For example, NSArray is an object that helps you with NSArray instances. So you can tell NSArray object to allocate memory for a NSArray object like :

[NSArray alloc]

and then you will send a message to the newly allocate instance to initialized itself.

[[NSArray alloc] init];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜