У меня есть массив, который я перебираю и передаю значение метке ячейки моего табличного представления.Но когда я передаю значения, метка показывает только последнее значение массива.Я хочу, чтобы он показывал целые элементы, поступающие из массива.Как я могу это показать?
let addonDescrip = ItemDataSource.sharedInstance.items[indexPath.row].addonDescp
print(addonDescrip)
for items in addonDescrip{
print(items)
cell.descriptionLbl.text = items
print(cell.descriptionLbl.text)
}
Я хочу, чтобы он отображал элементы в такой последовательности:
item1,
item2,
item4
Как мы можем показать это в метке ячейки табличного представления?Моя таблица просмотра делегатов,
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return ItemDataSource.sharedInstance.items.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 72
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = cartTableView.dequeueReusableCell(withIdentifier: "cartCell", for: indexPath) as! CartTableViewCell
cell.dishTitleLbl.text = ItemDataSource.sharedInstance.items[indexPath.row].itemName!
cell.priceLbl.text = ItemDataSource.sharedInstance.items[indexPath.row].totalPrice!
print(cell.priceLbl.text!)
let addonDescrip = ItemDataSource.sharedInstance.items[indexPath.row].addonDescp
print(addonDescrip)
for items in addonDescrip{
print(items)
cell.descriptionLbl.text = items
print(cell.descriptionLbl.text)
}
cell.quantityLbl.text = "1"//String(ItemDataSource.sharedInstance.items[indexPath.row].cartItem)
itemname = cell.dishTitleLbl.text!
itemDescription = cell.descriptionLbl.text!
itemprice = cell.priceLbl.text!
itemID = ItemDataSource.sharedInstance.items[indexPath.row].itemID!
cell.deleteBtn.tag = indexPath.row
cell.addBtn.tag = indexPath.row
cell.minusBtn.tag = indexPath.row
cell.deleteBtn.addTarget(self, action: #selector(crossBtnTapped), for: .touchUpInside)
cell.quantityLbl.layer.cornerRadius = 3
cell.quantityLbl.layer.borderColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)
cell.quantityLbl.layer.borderWidth = 1.5
cell.selectionStyle = .none
cell.delegate = self
return cell
}