Syntax question

Discussion in 'Mac Programming' started by larswik, Aug 28, 2010.

  1. macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    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
     
  2. Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Which language? I'd say either for most languages.
     
  3. macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #3
    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.
     
  4. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #4
    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
     
  5. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #5
    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
     
  6. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #6
    "Object" and "Instance" are fully equivalent synonyms. Ulsing them together is merely redundant - sort of like saying "follow the highway road."
     
  7. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #7
    Thanks. that is what I needed to know the mean the same thing.

    thanks!

    -Lars
     
  8. macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #8
    "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"
     

Share This Page