I have a collection say Array that contains objects that implement this protocol
protocol Observer {
func update(message: String)
}
let observers = [Observer]()
...
// usually I use this loop to tell all observers
for observer in observers {
observer.update(message: "updated")
}
What I want here is to do something like that:
observers.executeForAll{$0.update(message:"updated")}
I know this exists in other programming languages, but can this be done in swift.