I have a function in Objective-C. This function always returns a value, an event if an error occurs:
-(NSString *)test:(NSError **)error;
I override it in Swift1 as follows, so that I can still get the value and error at the same time.
override func test(error: NSErrorPointer) -> String {
var error: NSError?
let result = super.test(&error)
...
}
But now in swift2 I can only redefine the function, for example
override func test() throws -> String {
}
In this case, how to get the value and error at the same time?
I do this because I need to override the function in AFNetworking. Both return value and error are required.
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error;
source
share