【发布时间】:2015-11-27 02:25:50
【问题描述】:
所以我正在尝试遵循 wsdl2code 中的教程,他们在应用程序委托中实现 obj-c 协议(整个项目都在 Objective-c 中)。
我正在尝试快速重新创建它,但我一直被告知我不符合协议。我已经确保方法的 swift 版本中使用的类型正确地从 Objective-c 切换到 swift。
这是objective-c的头文件
#ifndef _Wsdl2CodeProxyDelegate
#define _Wsdl2CodeProxyDelegate
@protocol Wsdl2CodeProxyDelegate
//if service recieve an error this method will be called
-(void)proxyRecievedError:(NSException*)ex InMethod:(NSString*)method;
//proxy finished, (id)data is the object of the relevant method service
-(void)proxydidFinishLoadingData:(id)data InMethod:(NSString*)method;
@end
#endif
这是我的快速代码
class AppDelegate: UIResponder, UIApplicationDelegate, Wsdl2CodeProxyDelegate {
// MARK: Proxy protocol methods
func proxydidFinishLoadingData(data: AnyObject!, inMethod method: String!) {
print("Service \(method) done!")
}
func proxyRecievedError(ex: NSException!, inMethod method: String!) {
print("Exception in service \(method)")
}
【问题讨论】:
-
除了 Ethan 在下面指出的之外,ObjC 标头中的方法名称命名不佳 (...InMethod),但在 swift 中,您正在使用“inMethod”
-
这就是 xcode 的要求。它是骆驼式的,如果我改变它,它会告诉我它不像方法
标签: objective-c xcode swift