I want to use a for loop to set the titles for the button. What I am currently doing is not working. I thought using indexPath.row was working but it does not. The code is not compelling either. I would think there is a simple solution to implement the array.
var line = UIButton()
var pen = UIButton()
var graph = UIButton()
var save = UIButton()
var nxt = UIButton()
let btnTitles = ["line","pen","graph","save","next"]
var increase = 0.1
for b in [line, pen, graph,save,nxt] {
b.setTitle(btnTitles(IndexPath.row), for: .normal)
}
It prints as follows.
line pen graph save next