Reputation: 27
I made a array of type UIImageView, and a button that add new imageview to the array i want to name each new image with the order image1, image2, image3 .. etc
var array = [UIImageView]()
@IBAction func addImage(_ sender: Any)
let newImage = UIImageView()
self.view.addSubView(newImage)
array.append(newImage)
Upvotes: 0
Views: 39
Reputation: 6067
Instead using name you can work with tag
newImage.tag = array.count
array.append(newImage)
Upvotes: 1
Reputation: 736
You could use tags for that. Naming the variable dynamically isn't possible.
imageView.tag = X
Upvotes: 0