宣布代表

时间:2010-07-06 05:41:46

标签: objective-c pointers delegates

刚才意识到我声明的代表没有用指针类型声明。

所以代替这个

id <AddViewControllerDelegate> *delegate;

我有这个

id <AddViewControllerDelegate> delegate;

为什么最后一种方法是正确的?由于self是指针(我猜),那么为什么委托不是?

2 个答案:

答案 0 :(得分:2)

'id'已经是指针类型。它只是隐藏在typedef后面。

typedef id          (*IMP)(id, SEL, ...); 
typedef struct objc_class *Class;
typedef struct objc_object {
    Class isa;
} *id;

答案 1 :(得分:0)

id实际上是指向对象的指针。