Obj-c method with null return value not matching correct conversion to swift

I am having an issue where the following OBJ-C method won't convert to Swift with an extra return value:

- (nullable id)executeRequest:(ServerRequest *)request returningResponse:(__nullable NSURLResponse **__nullable)responseRef errorRef:(NSError **)errorRef

      

When trying to override this method in the swift class, it converts to this:

override func executeRequest(request: ServerRequest, returningResponse responseRef: AutoreleasingUnsafeMutablePointer<NSURLResponse?>) throws -> AnyObject

      

Note that the return value is AnyObject instead of AnyObject?

What am I doing wrong here? I am using X-Code 7 Beta 3

+3


source to share


1 answer


Swift imports Objective-C methods that out NSError **

throw an error ( as the last parameter) as the throw ( throws

) method . Because the method throws, the return type is not optional. The contract is that if a result is obtained nil

, then the method should throw an error.



+3


source







All Articles