Reputation: 717
I have an array :
let BRIArray = ["ATM BRI", "Internet Banking BRI"]
and then I count it at cellForRowAt:
let BRIArrayCount = BRIArray.count
and then I loop it :
for i in 0 ..< BRIArrayCount {
print (i) //i will increment up one with each iteration of the for loop
cell.lblBankPayment.text = "\(BRIArray[i])"
print("BRIArray: \(BRIArray[i])")
}
But the result just get last string and loop it like image below:
How to correct the loop inside cellForRowAt to show all array string in cell label text?
Upvotes: 0
Views: 284
Reputation: 326
No need to use loop instead of loop just use
cell.lblBankPayment.text = "(BRIArray[indexPath.row])"
if you want all the text in single label concat string in loop then set it
let str = "(str)(" ")(BRIArray[index])"
Upvotes: 2