我试图在
swift子类中覆盖这个
objective-c方法.我不断收到编译器错误:
来自AWSMTLModel
- (instancetype)initWithDictionary:(NSDictionary *)dictionary error:(NSError **)error
Swift子类
override func init!(dictionary dictionaryValue: [NSObject : AnyObject]!)//error: overriding declaration requires override keyword (fix it places override after func but gives same error
最佳答案 放下功能.
override init?(withDictionary dict: [NSObject : AnyObject])
此外,我会摆脱隐含的未解决的选项.如果init可能失败,请将其设为可选.如果dictionary参数是可选的,则创建另一个不带参数的便捷init,但它会创建一个默认字典并调用此init.