New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

why classes and objects are similar in objective c


Post Reply New Thread Subscribe

 
Thread Tools
harsha973

 
Member Since: Mar 08, 2010
Posts: 1
harsha973 is on a distinguished road

harsha973 is offline
I'm new to objective c.i got trough the point that objects and classes are same in objective c.i'm not getting this point how they can be same....

i need the explaination....


plzz reply mee......
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
I'm not sure what you are asking. Typically a class is useless without being instantiated into an object. A few classes can be useful without creating an object.

In object oriented languages, a class is a template for objects that will be based on it. You create objects by instantiating them from the class. The act of instantiating sets aside space for the variables you declared in the PERSON class, along with others that were inherited. So, if you have a PERSON class, you can create one or more PERSON objects (Frank, Kimberly, Jason) that use the model of PERSON. When you tell Frank to set his age to 32, you are using the method you wrote in the PERSON class, but it only affects age variable the Frank object. Kimberly and Jason have their own age variables.

I can't think of a short way of describing this all, so I point you to the following...

See Apples "The Objective-C Programming Language". On the left click on "Objects, Classes, and Messaging".

"Becoming an XCoder" might be useful too. Search for class and object. Perhaps page 37.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
Kludge

 
Member Since: May 10, 2010
Posts: 10
Kludge is on a distinguished road

Kludge is offline
The above post is not quite correct and is confusing instances of objects and the concept of an object.

A class IS an object. A class is just a way of denoting what the object is specifically. For instance if I said, "I have a thing." You know I have something but you don't know what. If I say, "I have a kitten." You know specifically what kind of thing I have. You don't know anything about a "thing" or what it might do but you do know a kitten will, probably, have fur and purr.

In the most basic of terms objects are things that have methods and properties (I'll avoid the idea of events to keep it simple). Then can be told to do things and they can have values associated with them. The word object describes that idea of having properties and methods. By itself it is just a concept.

A class then goes a step further and describes what kind of object a thing is, like a dog or a tree, and describes what methods and properties that object has. Like a dog might have a bark() method and a canBark property while a tree might have a shedLeaves() method and an isDeciduous property but a dog wouldn't shed leaves and trees don't bark; not even a dogwood.

So far we've talked about the idea of things but we haven't talked about how you get a copy of this idea of an object, what is called an instance. When you instantiate a class you create a copy of an object of type class which can then be manipulated.

Think of a class a blueprint. A blueprint is not a house itself but describes what a house should look like. When you build your house, when you instantiate it, you can then paint it, which is changing one of its properties, and you can turn on the airconditioner, which would be like using one of it's methods.

So, to recap a class IS an object, it's just a specific description of a KIND of object, while an instance is a copy of a class that can be manipulated.
QUOTE Thanks

Post Reply New Thread Subscribe


« C++ Windows compatibility? | ttys? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
New to Objective C - what is the problem with this? rb1383 OS X - Development and Darwin 1 04-22-2009 12:33 AM

All times are GMT -4. The time now is 01:59 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?