我正在寻找一种方法来声明委托(delegate)方法的实现有条件地相互链接。我知道 @required
和 @optional
标记特定方法的方式。但是我希望有一种方法可以根据需要标记一个方法,如果另一个方法被实现的话。这可能吗?
我喜欢做的事情是这样的:
考虑以下委托(delegate)方法:
- (void) firstSuccessDelegateMethod;
- (void) firstErrorDelegateMethod;
- (void) secondSuccessDelegateMethod;
- (void) secondErrorDelegateMethod;
有没有办法声明类似的东西
如果实现了firstSuccessDelegateMethod
,则需要firstErrorDelegateMethod
如果实现了secondSuccessDelegateMethod
,则需要secondErrorDelegateMethod
谢谢!
最佳答案
遗憾的是,这是不可能的,尽管您总是可以将两个委托(delegate)方法合并为一个,例如,
- (void)delegateMethodWithResult:(id)result error:(NSError *)error
关于ios - 在 iOS 中声明条件委托(delegate)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30704933/