I have a protocol:
protocol ProfileManagerDelegete {
func dataHaveUpdated(type: ReturnType)
}
and create a protocol array, and add/remove listener:
var listeners: [ProfileManagerDelegete] = []
func addListener(listener: ProfileManagerDelegete) {
listeners.append(listener)
}
func removeLister(listener: ProfileManagerDelegete) {
for lis in listeners {
if lis == listener { // this line error
//remove listener
}
}
}
Anyone can help ?
Because you have not told Swift how to compare 2 objects of type ProfileManagerDelegete
. Define a function:
protocol ProfileManagerDelegete {
func dataHaveUpdated(type: ReturnType)
}
func == (lhs: ProfileManagerDelegete, rhs: ProfileManagerDelegete) -> Bool {
// decide if they are equal
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With