* vs **

Discussion in 'Mac Programming' started by SqueegyX, Mar 24, 2008.

  1. macrumors regular

    Joined:
    Mar 24, 2008
    #1
    I've seen in some Objective-C code a double ** in variable declarations. For the most part, I understand the difference between with * and without. I know the difference between between a pointer non-pointer.

    But what would this mean?

    Code:
    NSString **myString;
    Is that a pointer to a pointer?
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Yep.
     
  3. thread starter macrumors regular

    Joined:
    Mar 24, 2008
    #3
    So what's the point of pointing to a pointer? Heh.
     
  4. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #4
    With pointers to pointers, you can quickly change the order in which you access data without physically moving any data.

    Also, if the data you are dealing with is all based in the heap, your structures will typically consist of pointers to data, rather than the actual data.

    The extra level of indirection can actually make programming simpler.
     

Share This Page