【发布时间】:2015-11-17 07:28:40
【问题描述】:
我正在尝试在 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方法
【问题讨论】:
标签: ios objective-c swift