So I'm attempting to follow a tutorial from wsdl2code where they are implementing the obj-c protocols in the app delegate ( the whole project is in objective-c).
因此,我正在尝试遵循wsdl2code的教程,在这个教程中,他们在app委托中实现object -c协议(整个项目都在objective-c中)。
I'm trying to recreate it in swift but I keep getting told that I'm not conforming to the protocol. I've made sure that the types used in the swift versions of the methods correctly swap over from objective-c to swift.
我试图用swift重新创建它,但我不断被告知我不符合协议。我已经确保在方法的swift版本中使用的类型正确地从objective-c切换到swift。
Here's the objective-c header
这是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
Here's my swift code
这是我的代码
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)")
}
1 个解决方案
#1
1
you should implement the protocol like this, 'Wsdl2CodeProxyDelegate' forget to implement the 'NSObject' protocol
您应该实现这样的协议,“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!) {
}
#1
1
you should implement the protocol like this, 'Wsdl2CodeProxyDelegate' forget to implement the 'NSObject' protocol
您应该实现这样的协议,“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!) {
}