我已经更新了 Xcode 7.3。我观察到 Xcode 没有显示错误(警告)来实现在自定义协议声明中标记为@required的委托方法。
项目正在成功构建,但没有实现必需的委托方法。但是,当我尝试在运行时调用委托方法时,它会给出“无法识别的选择器发送到实例”错误,该错误很明显,但我很好奇为什么 Xcode 在编译时停止显示它。
在旧版本中(例如 Xcode 6.4)它给出了。如果有人有任何想法,请分享。提前致谢。
这是我的协议声明,CustomViewController.h
#import <UIKit/UIKit.h>
@protocol MyCustomProtocol <NSObject>
- exampleDelegateMethod: (NSString*) test;
@end
@interface CustomViewController : UIViewController
@property (nonatomic, weak) id <MyCustomProtocol> delegate;
@end
在另一堂课中,我正在听我声明的委托方法,
在 .h 文件中,
#import "CustomViewController.h"
@interface AnotherViewController : UIViewController <MyCustomProtocol>
在 .m 文件中,
((CustomViewController*)segue.destinationViewController).delegate = self;