I have an array of Zombies, each Zombie is a struct as follows:
struct Zombie {
var number: Int
var location : Int
var health : Int
var uid : String
var group: Int
}
I have an array of Zombies
ZombieArray = [Zombie1, Zombie2, Zombie3]
I have to update the zombieHealth when it changes, but I need to find which Zombie it is first. Each zombie's Location, Number, and UID is unique, so any of those can be searched. Here's what I tried and got an error:
let zombieToUpdate : Zombie?
for zombieToUpdate in self.zombieArray {
if zombieToUpdate.location == thisZombieLocation {
let indexOfUpdateZombie = zombieArray.indexOf(zombieToUpdate)
self.zombieArray.remove(at: indexOfUpdateZombie)
self.zombieArray.append(thisNewZombie)
}
}
I'm getting the following error:
Cannot convert value of type 'Zombie' to expected argument type '(Zombie) throws -> Bool'
This error occurs on line:
let indexOfUpdateZombie = zombieArray.indexOf(zombieToUpdate)