我正在尝试在Swift中实现Objective-C的这个可选协议方法:
- (void)customHTTPProtocol:(CustomHTTPProtocol *)protocol logWithFormat:
(NSString *)format arguments:(va_list)arguments;
(参考: https://developer.apple.com/library/ios/samplecode/CustomHTTPProtocol/Introduction/Intro.html) 我已经用Swift编写了这个方法:
func customHTTPProtocol(`protocol`: CustomHTTPProtocol!, logWithFormat format: String!, arguments: CVaListPointer) {
}
它报错称无法满足可选要求,并建议在方法前添加@objc,但如果我添加@objc,则会出现错误(CVaListPointer无法在Objective-C中表示)。
问题在于此测试失败:
if ([strongDelegate respondsToSelector:@selector(customHTTPProtocol:logWithFormat:arguments:)]) {
而且这个swift方法没有被调用