* vs **

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

  1. SqueegyX
    Expand Collapse
    macrumors regular

    Mar 24, 2008
    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?

    NSString **myString;
    Is that a pointer to a pointer?
  2. Cromulent
    Expand Collapse
    macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
  3. SqueegyX
    Expand Collapse
    thread starter macrumors regular

    Mar 24, 2008
    So what's the point of pointing to a pointer? Heh.
  4. toddburch
    Expand Collapse
    macrumors 6502a

    Dec 4, 2006
    Katy, Texas
    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