У меня есть кнопка и табличное представление, когда я нажимаю на кнопку, будет показано табличное представление и перезагрузите его данные следующим образом:
@IBAction func citybtn(_ sender: Any) {
if citydrop.isHidden == false{
citydrop.isHidden = true
}else {
let filtered_shifts = myShifts.filter{$0.regionName == regionbtn.titleLabel?.text}
for shift in filtered_shifts {
cities.append(shift.cityName)
citiesid.append(shift.idCity)
}
uniqueCity = Array(Set(cities))
uniqueCityid = Array(Set(citiesid))
print(uniqueCity)
citydrop.isHidden = !citydrop.isHidden
contdurdrop.isHidden=true
nationalitydrop.isHidden=true
regiondrop.isHidden=true
btn=2
citydrop.isHidden=false
item = uniqueCity
citydrop.reloadData()
}
}
когда я нажимаю на кнопку города, она всегда вылетает и отображает эту ошибку:
отмечая, что у меня есть значения в uniqueCity ...
[ "Даммам"]
Я делаю то же самое с другой кнопкой, и она работает отлично!
так в чем проблема, почему я получаю эту ошибку?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = DropDownViewCell()
if (tableView == self.regiondrop){
cell = regiondrop.dequeueReusableCell(withIdentifier: "dropdowncell") as! DropDownViewCell
cell.item.text=item[indexPath.row]
return cell
}else if (tableView == self.citydrop){
cell = citydrop.dequeueReusableCell(withIdentifier: "dropdowncell1") as! DropDownViewCell
cell.item.text=item[indexPath.row]
return cell
}else if (tableView == self.contdurdrop){
cell = contdurdrop.dequeueReusableCell(withIdentifier: "dropdowncell2") as! DropDownViewCell
cell.item.text=item[indexPath.row]
return cell
}else if (tableView == self.nationalitydrop){
cell = nationalitydrop.dequeueReusableCell(withIdentifier: "dropdowncell3") as! DropDownViewCell
cell.item.text=item[indexPath.row]
return cell
}
return cell
}