I have declared a class method in Objective-C:
+ (id) someFunction:(NSDictionary *)param;
When I subclass the class and override this method in Swift with this:
override class func someFunction(param : NSDictionary) -> AnyObject?
I get the error:
Overriding method with selector 'someFunction:' has incompatible type '(NSDictionary) -> AnyObject?'
How do I override the method correctly?
When I try to autocomplete that class function from somewhere else in Swift, Xcode tells me that param is an [NSObject: AnyObject]!, which makes the method declaration work:
override class func someFunction(param: [NSObject: AnyObject]!) -> AnyObject? {
return "Foo"
}
This might be a compiler bug, since I'm pretty sure that's supposed to bridge properly to NSDictionary! (it seems to be bridging one way, but not the other, or something).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With