I have started learning Objective-C, and I just wanted to verify that my understanding of the concepts “class” and “object” is correct. If this is the wrong forum, for these kind of über basic questions, please inform where I should be heading!
Anyway, I am studying Objective-C from a book on the subject, and I am now trying to making the knowledge “my own”.
So far I have understood that “Class” refers to a description of the “objects” that can be “constructed” from this “Class”??? And that an “object” based on this “class” is understood by the specific “attributes” that this “object” can have and the specific “methods” this object can perform??? So “attributes” to me is similar to the physical description of the “object” and “methods” are the “actions” that this object can perform?
Your class basically describes the attributes and methods you can base an object on.
Your understanding seems to be correct but you described a little confusing.
Let me give you a quick example:
Think about a cat. This shall be your class.
It has the following attributes:
-Name
-Colour
-Gender
-…
And some methods:
-Scratch
-Walk
-Meow
-…
Now you know what a cat is and what it can do.
With this knowledge you can create objects based on your class, for example:
A cat object named “garfield” (an instance of the class “cat”) with the attributes:
Name: Garfield
Colour: Orange
Gender: Male
…
Which can scratch, walk, meow and… with it’s methods.
I hope that was quite understandable.
Greetz 🙂