Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

J V
1,774 PointsiOS objective-c: what's the definition and differences between objects and classes?
It would be nice to show one statement example for each. Please help I'm confused.
9 Answers

Kraig Walker
4,401 PointsA Class is a definition of something that will end up being an object - like a plan or a recipe. When you "create" a new class you're defining the properties and behaviours of this plan.
When you create an Object, you're actually using that plan to create a usable version of that plan in your program. Unless you deliberately set a limit, you can create many objects of the same class, but you cannot define classes of the same name (though classes of different names are obviously allowed to have the same recipe inside them, though it would be pretty wasteful...)

Ernest Grzybowski
Treehouse Project ReviewerClass is a blueprint.
An object is an instance of that class.
Example:
I have a car class. I have many car objects.

J V
1,774 PointsSo the objects are the variables?

Ernest Grzybowski
Treehouse Project ReviewerHey Joswell,
I see you started both Android and iOS, you should really start with Introduction to Programming. I'll write some really "pseudo" code to show you how you might use a "car" class.
Let's say this is my car class
public class Car{
make = "default"
model = "default"
color = "default"
}
As you noticed. It is very basic, but it covers 3 values of a car.
Now if I want to use my car class in my main application to create the 5 cars I own I can do this
Car car1 = new Car();
Car car2 = new Car();
Car car3 = new Car();
Car car4 = new Car();
Car car5 = new Car();
Now imagine I just added to more methods to my car class:
public void forward(){
move up 1 space;
}
public void backward(){
move down 1 space;
}
So then in my main program after I created my five different cars. I can say:
car1.forward();
car1.forward();
car1.backward();
car2.forward();
car2.forward();
car3.forward();
car3.forward();
car3.forward();
car4.forward();
car4.forward();
car5.forward();
That would give me:
car1 up one spot
car2 up two spots
car3 up three spots
car4 up two spots
car5 up one spots
Don't know if that helps you or confuses you, but it's supposed to show you that each object you create is it's own separate entity. The only tie it has to the class is the values given by that class and the methods in that class that it can use on itself.

J V
1,774 PointsHi Ernest,
I had this same idea of everything you just mentioned but I just wanted to double check. I just saw 1 video for android app and tried to launch eclipse but didn't work well on my last computer. So, I upgraded my computer and switched to iOS. I'm currently reading objective-c for dummies. Do you think learning the basics of c will help me? Do you know any good books on objective c (iOS development)? I will only stick to objective c iOS until I really master the language. I don't want to jump around. I want to stay focus. I will work very hard to learn this language.

Ernest Grzybowski
Treehouse Project RevieweriOS and Android are both great platforms. I would develop on whichever platform you currently own. I have a lot of android devices so I develop mainly on Android in the Java programing language. iOS applications are built using Objective-C. Java and Objective-C are Object Oriented Programming languages. This means that concepts between the two are very similar. Both really revolve around classes and creating objects of these classes. As Ben pointed out on the forum earlier today, you can really succeed at a certain topic if you combine other outside resources as well. If you want to read about Objective-C there are plenty of books. I've been digging into iOS for the past couple of months. A few resources that helped:
Keep coding! It will not happen overnight. Learning a programming language may be one of the toughest things you ever do, but treehouse can help!

Ben Jakuben
Treehouse TeacherHey @Joswell,
Nice to see some great answers in here! If you haven't gotten to this video in the Android course yet, I talk about objects and classes in the beginning and then we write code for a class the defines how an object will work. As the others have mentioned, it's a concept that just takes a little time to get used to.
For Objective C, @Amit has listed some helpful materials in this other post: https://teamtreehouse.com/forum/objective-c
I'm also working on a few blog posts regarding Objective C basics much like I wrote for Java. I hope to have those on the blog by the end of May. Here are the Java ones if you're interested:

J V
1,774 PointsThanks Ben, I'm just focused on iOS development at this point. I want to master objective c and Develop some applications. Sometime, down the road I will Learn android development. I wAnt to take things one step at a time.
I will check out @amit objective c post and I look forward for your blog post.

Pavel Palancica
6,535 PointsTo make analogy to the real world, a class is like the plan/design (on paper, for instance) of a house (it has dimensions, number of doors, windows etc), and an object is the house itself :)