将我的代码转换为 swift 3 后,出现错误:
noteObjects.sort (comparator: { (first : AnyObject, second : AnyObject) -> ComparisonResult in
if let f : String = (first as! RChannels).name! {
let s : String = (second as! RChannels).name!
return f.compare(s)
}
} as! (Any, Any) -> ComparisonResult) // error here
这一行as! (Any, Any) -> ComparisonResult)
给了我一个错误,上面写着(lldb),没有任何其他描述,任何人都可以解释这里出了什么问题?在转换之前是这样的:
noteObjects.sortUsingComparator { (first : AnyObject, second : AnyObject) -> NSComparisonResult in
if let f : String = (first as! RChannels).name! {
let s : String = (second as! RChannels).name!
return f.compare(s)
}
}
noteObjects
是一个 NSMutableArray