if (model.classForCoder.respondsToSelector("rangeKeyAttribute")) {
let rangeKeyAttribute = model.classForCoder.rangeKeyAttribute!()
let index = keys.indexOf(rangeKeyAttribute)
if let index = index {
keys.removeAtIndex(index)
keys.insert(rangeKeyAttribute, atIndex: 0)
}
}
这段代码以前工作正常,但是在Swift 3中编译器说不推荐这样做了:
if (model.classForCoder.respondsToSelector("rangeKeyAttribute")) {
应改为:
if (model.classForCoder.responds(to: #selector(AWSDynamoDBModeling.rangeKeyAttribute))) {
Swift 3不喜欢这个并且抛出错误:
无法调用非函数类型的值'((选择器) - > Bool)!'
我似乎无法弄清楚如何让Swift 3接受!