How to override objective-c method in swift

I am trying to override this objective-c method in a quick subclass. I keep getting compiler errors:

From AWSMTLModel

- (instancetype)initWithDictionary:(NSDictionary *)dictionary error:(NSError **)error

Subclass Swift

override func init!(dictionary dictionaryValue: [NSObject : AnyObject]!)//error: overriding declaration requires override keyword (fix it places override after func but gives same error
+4
source share
1 answer

Drop the function.

override init?(withDictionary dict: [NSObject : AnyObject])

In addition, I would get rid of implicitly deployed options. If init can fail, make it optional. If the dictionary parameter is optional, create another convenient initialization that does not accept any parameters, but creates a default dictionary and calls this init.

+2
source

Source: https://habr.com/ru/post/1606478/


All Articles