Cannot convert value of type 'UIImage' to expected argument type 'String'
I am trying to create a book, and if I type in the name of the picture I want in the UIImageView constructor which is "cup", my program executes correctly and displays the same picture on every page. If I try and do "imageNames[element]" to get all my pictures displayed depending on page within my for loop it says it can not convert UIImage to String
var imageNames: [UIImage] = [
UIImage(named: "open")!,
UIImage(named: "cup")!
]
for element in 0 ..< imageNames.count {
let vc = UIViewController()
vc.view.backgroundColor = randomColor()
//Where error is occurring!
let imageView = UIImageView(image: UIImage(named:
imageNames[element]))
vc.view.addSubview(imageView)
}
I would think that imageNames[element] would give me the String value in the array. My goal is that when I open the book.... "open" picture is on the first page, and "cup" picture is on the second page.