Consider this Objective-C class:
@interface TestAPI : NSObject
-(nullable id)aNullableMethod;
-(nullable id)aNullableMethodWithError:(inout NSError **)error;
@end
I'm using TestAPI
as an abstract base class and want to inherit from it in Swift.
Swift bridges this code to look like this (i.e. Counterparts menu -> Swift 4.2 Interface):
open class TestAPI : NSObject {
open func aNullableMethod() -> Any?
open func aNullableMethodWithError() throws -> Any
}
The problem is that aNullableMethodWithError()
can return nil
as a valid value.
How do I convince Swift that aNullableMethodWithError()
returns Any?
and not Any
?
Or is there a better way to write the Objective-C method signature?