Mohmed Showekh
Mohmed Showekh

Reputation: 27

XCode - Making ordered names imageView array?

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

Answers (2)

Abdelahad Darwish
Abdelahad Darwish

Reputation: 6067

Instead using name you can work with tag

newImage.tag = array.count

array.append(newImage)

Upvotes: 1

chronikum
chronikum

Reputation: 736

You could use tags for that. Naming the variable dynamically isn't possible.

imageView.tag = X

Upvotes: 0

Related Questions