<分区>
var items = [LiveCellProtocol]() //unsorted array
public class User: LiveCellProtocol {
...
}
let mike = User()
items.append(mike)
items.indexOf(mike) //throws an error
Cannot convert value of type 'LiveCellProtocol' to expected argument type '@noescape (LiveCellProtocol) throws -> Bool'
我该如何解决这个问题?我真的很想使用 .indexOf
方法。有针对这个的解决方法吗?
现在,我正在通过遍历每个项目来破解解决方案,这是线性时间。