在我将Swift 1更新为Swift 2.0后,我遇到了一个问题.
我在代码的第一行遇到以下错误:
方法无法标记为@objc,因为参数的类型无法在Objective-C中表示
@objc func personsToFirstStep(persons: [Person]) {
for person in persons {
if !self.persons.contains(person) && person.id != userID {
self.persons.append(person)
}
}
collectionView.reloadData()
collectionViewPlaceholder.hidden = true
collectionView.hidden = false
collectionGradientView.hidden = false
}
这类人:
class Person: Hashable {
var intID: Int = 0
var id: String = ""
var name: String = ""
var type: String = ""
var hashValue: Int {
return self.intID
}
init(id: String, name: String, type: String) {
self.id = id
self.intID = Int(id)!
self.name = name
self.type = type
}
}
func ==(lhs: Person, rhs: Person) -> Bool {
return lhs.intID == rhs.intID
}