5

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

From AWSMTLModel

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

Swift subclass

override func init!(dictionary dictionaryValue: [NSObject : AnyObject]!)//error: overriding declaration requires override keyword (fix it places override after func but gives same error
Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148
joels
  • 7,249
  • 11
  • 53
  • 94

1 Answers1

3

Drop the func.

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

Also, I would get rid of the implicitly unwrapped optionals. If the init can fail, make it an optional. If the dictionary parameter is optional, create another convenience init that takes no parameters, but which creates a default dictionary and calls this init.

Mr Beardsley
  • 3,743
  • 22
  • 28