Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 是否可以将变量重新声明为其他类型? @协议BGTableViewDelegateMother @结束 @接口BGTableViewDelegateMother:NSObject @属性(弱、非原子)UITableView*tv; @属性id委托; @结束_Objective C - Fatal编程技术网

Objective c 是否可以将变量重新声明为其他类型? @协议BGTableViewDelegateMother @结束 @接口BGTableViewDelegateMother:NSObject @属性(弱、非原子)UITableView*tv; @属性id委托; @结束

Objective c 是否可以将变量重新声明为其他类型? @协议BGTableViewDelegateMother @结束 @接口BGTableViewDelegateMother:NSObject @属性(弱、非原子)UITableView*tv; @属性id委托; @结束,objective-c,Objective C,后一种说法是我想继承母亲 但是,我想将委托的类型更改为其他类型。也许不是,但是。可能吗 当然,BGIhaveNavigationControllerandsomeotherthing继承自BGIhaveNavigationController,只要子类的委托所遵循的协议包含BGIhaveNavigationController协议就可以了。您可以这样做: @protocol BGTableViewDelegateMother <BGIhaveNavigationController>

后一种说法是我想继承母亲

但是,我想将委托的类型更改为其他类型。也许不是,但是。可能吗


当然,BGIhaveNavigationControllerandsomeotherthing继承自BGIhaveNavigationController

,只要子类的委托所遵循的协议包含BGIhaveNavigationController协议就可以了。您可以这样做:

@protocol BGTableViewDelegateMother <BGIhaveNavigationController>



@end

@interface BGTableViewDelegateMother : NSObject
@property (weak,nonatomic) UITableView * tv;
@property id <BGIhaveNavigationController> delegate;
@end
@protocol BGIhaveNavigationControllerAndSomethingElse
-(空)某物;
@结束
@接口BGTableViewDelegateChild:BGTableViewDelegateMother
@属性id委托;
@结束
请注意,如果bgihavenigationcontrollerandsomethingelse声明为

@protocol BGIhaveNavigationControllerAndSomethingElse <BGIhaveNavigationController>
- (void)somethingElse;
@end

@interface BGTableViewDelegateChild : BGTableViewDelegateMother
@property id <BGIhaveNavigationControllerAndSomethingElse> delegate;
@end
@protocol BGIhaveNavigationControllerAndSomethingElse

(也就是说,没有合并BGIhaveNavigationController)然后编译器会抱怨
BGIhaveNavigationController
的委托类型。

对于委托属性,你的意思是什么?@pnizzle:是的,我今晚有很多打字错误……谢谢。当然,我没有挑剔你,我只是想从你的回答中理解这个问题!
@protocol BGIhaveNavigationControllerAndSomethingElse <NSObject>