Sarimin
Sarimin

Reputation: 717

looping tableview cell label text from an array

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: enter image description here

How to correct the loop inside cellForRowAt to show all array string in cell label text?

Upvotes: 0

Views: 284

Answers (1)

234 Shk
234 Shk

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

Related Questions