PDA

View Full Version : * vs **




SqueegyX
Mar 24, 2008, 02:15 PM
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?



Cromulent
Mar 24, 2008, 02:17 PM
Is that a pointer to a pointer?

Yep.

SqueegyX
Mar 24, 2008, 02:58 PM
So what's the point of pointing to a pointer? Heh.

toddburch
Mar 24, 2008, 03:06 PM
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.