views:

1112

answers:

5

So, I saw this:

error:(NSError **)error

in the apple doc's. Why two stars? What is the significance?

+1  A: 

If it is anything like C then ** means a pointer to a pointer.

Andrew Hare
Objective-C is a strict superset of C. Nothing from C is any different.
Peter Hosey
+5  A: 

In C, a double star is a pointer to a pointer. There are a couple of reasons to do this. First is that the pointer might be to an array of pointers. Another reason would be to pass a pointer to a function, where the function modifies the pointer (similar to an "out" parameter in other languages).

geofftnz
+15  A: 

A "double star" is a pointer to a pointer. So NSError ** is a pointer to a pointer to an object of type NSError. It basically allows you to return an error object from the function. You can create a pointer to an NSError object in your function (call it *myError), and then do something like this:

*error = myError;

to "return" that error to the caller.

mipadi
+5  A: 

In C everything is pass by value. If you want to change the value of something you pass the address of it (which passes the value of the memory address). If you want to change where a pointer points you pass the the addres of the pointer.

Take a look here for a simple explanation.

TofuBeer
+6  A: 

It is a song by the Rolling Stones

http://en.wikipedia.org/wiki/Star_Star

Otávio Décio
Hard to decide whether to vote it up or down. :)
Georg
Monday afternoon is tough... :)
Otávio Décio