A quick beginner question

Discussion in 'Mac Programming' started by Meriana, Nov 30, 2009.

  1. Meriana macrumors member

    Joined:
    Aug 31, 2009
    #1
    Hi everyone

    I'm sure if read it, but i can't find it in the book about Objective-C 2.0 i'm using anymore:

    What means the * infront of a the name of a new instance of an class:

    Code:
    NSObjects [B]*[/B]newObject 
    
    or in cases like this:
    -(void)setName:(NSString [B]*[/B])newName
    thanks in advance.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
  3. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    In Objective-C every object is stored on the heap, with pointers on the stack used to access them (via message passing). Because of this, every object instance you're dealing with will be via pointer. You can also have pointers to primitive types, just as in C, but these are going to be treated differently. They will be manipulated using * to dereference, etc instead of having messages passed. You can probably get by without it, but this is a major reason I think a foundation in C helps when learning Objective-C.

    -Lee
     
  4. Meriana thread starter macrumors member

    Joined:
    Aug 31, 2009
    #4
    Well thanks. :)

    Though either i have a really good book or Objective-C 2.0 is really easy to learn.

    Do you think i should get myself a book with a quick introduction to C?
     
  5. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #5
    I do. Other people disagree. I think a foundation in C is helpful, but it's probably not strictly necessary. I feel like knowing C is a net positive, I don't think anything you learn will be useless in other languages.

    -Lee
     
  6. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #6
    You might want to have a look at this tutorial. It has a really great section on how memory works, that should prove helpful. I don't think you need to be a C guru to work through introductory Cocoa books, but a solid understanding of the fundamental concepts (such as memory management, pointers, variable scope etc.) is pretty essential.
     

Share This Page