Pablo
Pablo

Reputation: 29519

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?

Upvotes: 1

Views: 224

Answers (2)

Conceited Code
Conceited Code

Reputation: 4557

id is actually a pointer to an object.

Upvotes: 0

Joshua Weinberg
Joshua Weinberg

Reputation: 28688

'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;

Upvotes: 2

Related Questions