所以我试图遵循wsdl2code的教程,他们在app delegate中实现obj-c协议(整个项目在objective-c中)。
我正试图在swift中重新创建它,但我不断被告知我不符合协议。我已经确保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)")
}
答案 0 :(得分:1)
你应该像这样实施协议,' Wsdl2CodeProxyDelegate'忘记实施'NSObject'协议
@protocol Wsdl2CodeProxyDelegate <NSObject>
//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
func proxydidFinishLoadingData(data: AnyObject!, inMethod method: String!) {
}
func proxyRecievedError(ex: NSException!, inMethod method: String!) {
}