vendredi 6 juillet 2018

Setting variable equal to if statement condition

I have an if statement that checks to see if an array element matches a local variable.

 if pinArray.contains(where: {$0.title == restaurantName})

How would I create a variable of this element? I attempted

 let thePin = pinArray.contains(where: {$0.title == restaurantName}) 

but this comes with "could not cast boolean to MKAnnotation".

I also tried variations of

let pins = [pinArray.indexPath.row]
let pinn = pins(where: pin.title == restaurantName) (or close to it)

mapp.selectAnnotation(thePin as! MKAnnotation, animated: true)

to no avail. What basic step am I missing?

Aucun commentaire:

Enregistrer un commentaire