I have the next code
var i = 0
for answer in answeres{
let singleTap = UITapGestureRecognizer(target: self, action:#selector(tapDetected(_:))
imageView.addGestureRecognizer(singleTap)
i+=1
}
func tapDetected(position : Int) {
print(position)
}
How can I pass the var 'i' to each imageView, so when the user click the imageView, it prints the correct number in the log?