1

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,

1 Answer 1

3

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];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.