PDA

View Full Version : Syntax question




larswik
Aug 29, 2010, 12:34 AM
After I defining a Class. You create an instance of that Class which is then called an Object, Instance Object or both?

Trying to get my syntax down so I can communicate better with problems.

-Lars



angelwatt
Aug 29, 2010, 07:39 AM
Which language? I'd say either for most languages.

jared_kipe
Aug 29, 2010, 12:06 PM
In Objective-C, an Object is, most basically, something you can message.

There are Class objects, every time you write something like [NSArray alloc] you are messaging the Class object.

Class methonds like -alloc or [NSNumber numberWithDouble: 2.0] return instances. And instances respond to instance messages like -objectAtIndex:

You can usually have as many instances as you want, but there is only one Class object for each class.

larswik
Aug 29, 2010, 05:12 PM
Gotcha, I understand how how it works but I am just failing to use the right terminology (syntax) to describe my problems. in my Class in the @interface I create what are called 'instance variables' and 'method headers'. Then in the @implementation section I define the methods for the @interface section.

Now in 'main', what is the correct way of saying this: "from the Class I create an Object", or "from the Class I create an Instance Object"?

-Lars

lee1210
Aug 29, 2010, 05:19 PM
I'd probably say "Object of class x" or "instance of class x" or even "instance of x". "Instance object" isn't wrong, per se, just a bit verbose.

-Lee

Sydde
Aug 29, 2010, 06:01 PM
"Object" and "Instance" are fully equivalent synonyms. Ulsing them together is merely redundant - sort of like saying "follow the highway road."

larswik
Aug 29, 2010, 08:05 PM
Thanks. that is what I needed to know the mean the same thing.

thanks!

-Lars

jared_kipe
Aug 30, 2010, 01:27 PM
Now in 'main', what is the correct way of saying this: "from the Class I create an Object", or "from the Class I create an Instance Object"?

-Lars

"I create an instance of "class"" or "I create a "class" instance" or "I create a "class""

All of them make more sense with an actual class name.

"I create an instance of NSNumber"
"I create a NSString instance"
"I create an NSArray"