views:

45

answers:

2
+1  Q: 

Declaring delegate

Just realized that the delegates I am declaring are not declared with pointer type.

so instead of this

id <AddViewControllerDelegate> *delegate;

I have this

id <AddViewControllerDelegate> delegate;

Why the last way is correct? Since self is pointer(I guess) then why delegate is not?

+2  A: 

'id' is already a pointer type. It's just hidden behind the typedef.

typedef id          (*IMP)(id, SEL, ...); 
typedef struct objc_class *Class;
typedef struct objc_object {
    Class isa;
} *id;
Joshua Weinberg
@Joshua Weinberg: Where are those header files located?
Michael
A: 

id is actually a pointer to an object.

Conceited Code
There isn't anything wrong with a pointer to a pointer. The compiler doesn't dislike them. They're perfectly valid, just not the same thing as a pointer to an object.
Chuck