Anonymous
Swift 3: фильтрация результатов по идентификаторам и перезагрузка таблицы
Сообщение
Anonymous » 05 янв 2025, 18:38
Я пытаюсь понять, как отфильтровать данные и перезагрузить представление таблицы.
У меня есть 4 региона (Север, Юг, Восток и Запад) и все.По умолчанию отображаются все профили.
Если я нажму «Север» (т. е. 1), будут фильтроваться только профили, доступные в северном регионе.
Аналогично с югом, востоком и запад. В зависимости от нажатого региона должна фильтроваться профиль.
Код: Выделить всё
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0
{
let cell = self.businessTableView.dequeueReusableCell(withIdentifier: "businessCell", for: indexPath) as! BusinessCell
let tableObjects:StorageSubCatagoriezTwo = subCatagorizeDataTwo[indexPath.row]
let charCheck = (tableObjects.address).replacingOccurrences(of: " ", with: "")
cell.businessWebView.scrollView.isScrollEnabled = false
var strings = ""
if regId == 1
{
cell.businessName.text = " "
let tableObjects:StorageSubCatagoriezTwoNorth = subCatagorizeDataTwoN[indexPath.row]
if tableObjects.address.characters.isEmpty != true
{
strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "")
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
strings = strings+(tableObjects.telephone.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.telephone+"
" : "")
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
strings = strings+(tableObjects.email.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.email+"
" : "")
}
else
{
}
if tableObjects.website.characters.isEmpty != true{
strings = strings+(tableObjects.website.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.website : "")
}
else{
}
}
else if regId == 2
{
cell.businessName.text = " "
let tableObjects:StorageSubCatagoriezTwoEast = subCatagorizeDataTwoE[indexPath.row]
//cell.businessName.text = tableObjects.nameString
if tableObjects.address.characters.isEmpty != true
{
// cell.businessName.text = tableObjects.nameString
strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "")
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
strings = strings+(tableObjects.telephone.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.telephone+"
" : "")
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
strings = strings+(tableObjects.email.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.email+"
" : "")
}
else
{
}
if tableObjects.website.characters.isEmpty != true{
strings = strings+(tableObjects.website.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.website : "")
}
else{
}
}
else if regId == 3
{
cell.businessName.text = " "
let tableObjects:StorageSubCatagoriezTwoSouth = subCatagorizeDataTwoS[indexPath.row]
// cell.businessName.text = tableObjects.nameString
if tableObjects.address.characters.isEmpty != true
{
//cell.businessName.text = tableObjects.nameString
strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "")
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
strings = strings+(tableObjects.telephone.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.telephone+"
" : "")
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
strings = strings+(tableObjects.email.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.email+"
" : "")
}
else
{
}
if tableObjects.website.characters.isEmpty != true{
strings = strings+(tableObjects.website.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.website : "")
}
else{
}
}
else if regId == 4
{
cell.businessName.text = " "
let tableObjects:StorageSubCatagoriezTwoWest = subCatagorizeDataTwoW[indexPath.row]
// cell.businessName.text = tableObjects.nameString
if tableObjects.address.characters.isEmpty != true
{
// cell.businessName.text = tableObjects.nameString
strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "")
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
strings = strings+(tableObjects.telephone.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.telephone+"
" : "")
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
strings = strings+(tableObjects.email.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.email+"
" : "")
}
else
{
}
if tableObjects.website.characters.isEmpty != true{
strings = strings+(tableObjects.website.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.website : "")
}
}
else{
let tableObjects:StorageSubCatagoriezTwo = subCatagorizeDataTwo[indexPath.row]
cell.businessName.text = tableObjects.nameString
let charCheck = (tableObjects.address).replacingOccurrences(of: " ", with: "")
print(charCheck)
cell.businessName.text = " "
var strings = ""
strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "")
strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.address+"[/b][b]" : "")
// strings = strings+(tableObjects.address.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.address+"
" : "")
strings = strings+(tableObjects.telephone.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.telephone+"
" : "")
strings = strings+(tableObjects.email.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.email+"
" : "")
strings = strings+(tableObjects.website.characters.count > 0 ? "
[img]\[/img]
"+tableObjects.website : "")
// cell.businessWebView.loadHTMLString(""+tableObjects.nameString+"[/b]
[img]\[/img]
"+tableObjects.address+"
[img]\[/img]
"+tableObjects.telephone+"
[img]\[/img]
"+tableObjects.email+"
[img]\[/img]
"+tableObjects.website, baseURL: nil)
cell.businessWebView.loadHTMLString(strings, baseURL: nil)
let heightIndex = strings.components(separatedBy: "
")
let heightMul = heightIndex.count
print(heightMul*32)
self.heightOfTheCell = CGFloat(((heightMul)*32)+4)
}
return cell
}
else if indexPath.section == 1
{
let cell = self.businessTableView.dequeueReusableCell(withIdentifier: "businessCell2")
cell?.textLabel?.textAlignment = .center
switch regId
{
case 0:
if subCatagorizeDataTwo.count != forAll
{
cell?.textLabel?.text = "LOAD MORE DATA"
cell?.textLabel?.textColor = Color.whiteColor
cell?.backgroundColor = UIColor.darkGray
}else{
cell?.textLabel?.text = "NO MORE FOUND!"
cell?.textLabel?.textColor = UIColor.darkGray
cell?.backgroundColor = UIColor.gray
cell?.selectionStyle = UITableViewCellSelectionStyle.none
}
case 1:
if subCatagorizeDataTwoN.count != forN
{
cell?.textLabel?.text = "LOAD MORE DATA"
cell?.textLabel?.textColor = Color.whiteColor
cell?.backgroundColor = UIColor.darkGray
}else{
cell?.textLabel?.text = "NO MORE FOUND!"
cell?.textLabel?.textColor = UIColor.darkGray
cell?.backgroundColor = UIColor.gray
cell?.selectionStyle = UITableViewCellSelectionStyle.none
}
case 2:
if subCatagorizeDataTwoE.count != forE
{
cell?.textLabel?.text = "LOAD MORE DATA"
cell?.textLabel?.textColor = Color.whiteColor
cell?.backgroundColor = UIColor.darkGray
}else{
cell?.textLabel?.text = "NO MORE FOUND!"
cell?.textLabel?.textColor = UIColor.darkGray
cell?.backgroundColor = UIColor.gray
cell?.selectionStyle = UITableViewCellSelectionStyle.none
}
case 3:
if subCatagorizeDataTwoS.count != forS
{
cell?.textLabel?.text = "LOAD MORE DATA"
cell?.textLabel?.textColor = Color.whiteColor
cell?.backgroundColor = UIColor.darkGray
}else{
cell?.textLabel?.text = "NO MORE FOUND!"
cell?.textLabel?.textColor = UIColor.darkGray
cell?.backgroundColor = UIColor.gray
cell?.selectionStyle = UITableViewCellSelectionStyle.none
}
case 4:
if subCatagorizeDataTwoW.count != forW
{
cell?.textLabel?.text = "LOAD MORE DATA"
cell?.textLabel?.textColor = Color.whiteColor
cell?.backgroundColor = UIColor.darkGray
}else{
cell?.textLabel?.text = "NO MORE FOUND!"
cell?.textLabel?.textColor = UIColor.darkGray
cell?.backgroundColor = UIColor.gray
cell?.selectionStyle = UITableViewCellSelectionStyle.none
}
default:break
}
return cell!
}
else
{
let tableObjects:StorageSubCatagoriez3rd = SubCatagoriez3rd[indexPath.row]
let cell = self.businessTableView.dequeueReusableCell(withIdentifier: "businessCell3")
cell?.textLabel?.text = tableObjects.nameString
return cell!
}
}
Смотрите скриншот:
И, как видно во втором Снимок экрана (Южный регион). Профиль должен был быть скрыт, поскольку он принадлежит Северному региону.
Пожалуйста, дайте мне знать, как это исправить.
Спасибо за время
Модель:
Код: Выделить всё
class StorageSubCatagoriezTwo
{
var nameString:String
var idString:String
var address:String
var telephone:String
var email:String
var website:String
init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String)
{
self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
class StorageSubCatagoriezTwoNorth
{
var nameString:String
var idString:String
var address:String
var telephone:String
var email:String
var website:String
init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String)
{
self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
class StorageSubCatagoriezTwoEast
{
var nameString:String
var idString:String
var address:String
var telephone:String
var email:String
var website:String
init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String)
{
self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
class StorageSubCatagoriezTwoWest
{
var nameString:String
var idString:String
var address:String
var telephone:String
var email:String
var website:String
init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String)
{
self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) }
}
class StorageSubCatagoriezTwoSouth
{
var nameString:String
var idString:String
var address:String
var telephone:String
var email:String
var website:String
init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String)
{
self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
Извлечение региона и присвоение переменной:
Код: Выделить всё
let id = String(describing: dictionary["id"]!)
let name = String(describing: dictionary["BUSINESS_NAME"]!)
let email = String(describing: dictionary["EMAIL"]!)
var streetNo = String(describing: dictionary["STREET_NO"]!)
var streetName = String(describing: dictionary["STREET_NAME"]!)
var suburbID = String(describing: dictionary["SUBURB_ID"]!)
var postCode = String(describing: dictionary["POSTCODE"]!)
let regionID = String(describing: dictionary["REGION_ID"]!)
var landline = String(describing: dictionary["PHONE_FIXED"]!)
var mobile = String(describing: dictionary["PHONE_MOBILE"]!)
let website = String(describing: dictionary["WEBURL"]!)
var suburbName = String(describing: dictionary["Suburb"]!)
let streedNoHide = String(describing: dictionary["STREET_NO_HIDDEN"]!)
let streetNameHide = String(describing: dictionary["STREET_NAME_HIDDEN"]!)
let suburbHide = String(describing: dictionary["SUBURB_HIDDEN"]!)
let postCodeHide = String(describing: dictionary["POSTCODE_HIDDEN"]!)
let mobileHide = String(describing: dictionary["PHONE_MOBILE_HIDDEN"]!)
let landlineHide = String(describing: dictionary["PHONE_FIXED_HIDDEN"]!)
ДАННЫЕ JSON: (REGION_ID)
[img]
https://i.sstatic.net /72Y2M.png[/img]
Подробнее здесь:
https://stackoverflow.com/questions/454 ... -tableview
1736091520
Anonymous
Я пытаюсь понять, как отфильтровать данные и перезагрузить представление таблицы.[b]У меня есть 4 региона (Север, Юг, Восток и Запад) и все.По умолчанию отображаются все профили. Если я нажму «Север» (т. е. 1), будут фильтроваться только профили, доступные в северном регионе. Аналогично с югом, востоком и запад. В зависимости от нажатого региона должна фильтроваться профиль. [code]func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if indexPath.section == 0 { let cell = self.businessTableView.dequeueReusableCell(withIdentifier: "businessCell", for: indexPath) as! BusinessCell let tableObjects:StorageSubCatagoriezTwo = subCatagorizeDataTwo[indexPath.row] let charCheck = (tableObjects.address).replacingOccurrences(of: " ", with: "") cell.businessWebView.scrollView.isScrollEnabled = false var strings = "" if regId == 1 { cell.businessName.text = " " let tableObjects:StorageSubCatagoriezTwoNorth = subCatagorizeDataTwoN[indexPath.row] if tableObjects.address.characters.isEmpty != true { strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "") } else { //nothing } if tableObjects.telephone.characters.isEmpty != true { strings = strings+(tableObjects.telephone.characters.count > 0 ? " [img]\[/img] "+tableObjects.telephone+" " : "") } else { } if tableObjects.email.characters.isEmpty != true { strings = strings+(tableObjects.email.characters.count > 0 ? " [img]\[/img] "+tableObjects.email+" " : "") } else { } if tableObjects.website.characters.isEmpty != true{ strings = strings+(tableObjects.website.characters.count > 0 ? " [img]\[/img] "+tableObjects.website : "") } else{ } } else if regId == 2 { cell.businessName.text = " " let tableObjects:StorageSubCatagoriezTwoEast = subCatagorizeDataTwoE[indexPath.row] //cell.businessName.text = tableObjects.nameString if tableObjects.address.characters.isEmpty != true { // cell.businessName.text = tableObjects.nameString strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "") } else { //nothing } if tableObjects.telephone.characters.isEmpty != true { strings = strings+(tableObjects.telephone.characters.count > 0 ? " [img]\[/img] "+tableObjects.telephone+" " : "") } else { } if tableObjects.email.characters.isEmpty != true { strings = strings+(tableObjects.email.characters.count > 0 ? " [img]\[/img] "+tableObjects.email+" " : "") } else { } if tableObjects.website.characters.isEmpty != true{ strings = strings+(tableObjects.website.characters.count > 0 ? " [img]\[/img] "+tableObjects.website : "") } else{ } } else if regId == 3 { cell.businessName.text = " " let tableObjects:StorageSubCatagoriezTwoSouth = subCatagorizeDataTwoS[indexPath.row] // cell.businessName.text = tableObjects.nameString if tableObjects.address.characters.isEmpty != true { //cell.businessName.text = tableObjects.nameString strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "") } else { //nothing } if tableObjects.telephone.characters.isEmpty != true { strings = strings+(tableObjects.telephone.characters.count > 0 ? " [img]\[/img] "+tableObjects.telephone+" " : "") } else { } if tableObjects.email.characters.isEmpty != true { strings = strings+(tableObjects.email.characters.count > 0 ? " [img]\[/img] "+tableObjects.email+" " : "") } else { } if tableObjects.website.characters.isEmpty != true{ strings = strings+(tableObjects.website.characters.count > 0 ? " [img]\[/img] "+tableObjects.website : "") } else{ } } else if regId == 4 { cell.businessName.text = " " let tableObjects:StorageSubCatagoriezTwoWest = subCatagorizeDataTwoW[indexPath.row] // cell.businessName.text = tableObjects.nameString if tableObjects.address.characters.isEmpty != true { // cell.businessName.text = tableObjects.nameString strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "") } else { //nothing } if tableObjects.telephone.characters.isEmpty != true { strings = strings+(tableObjects.telephone.characters.count > 0 ? " [img]\[/img] "+tableObjects.telephone+" " : "") } else { } if tableObjects.email.characters.isEmpty != true { strings = strings+(tableObjects.email.characters.count > 0 ? " [img]\[/img] "+tableObjects.email+" " : "") } else { } if tableObjects.website.characters.isEmpty != true{ strings = strings+(tableObjects.website.characters.count > 0 ? " [img]\[/img] "+tableObjects.website : "") } } else{ let tableObjects:StorageSubCatagoriezTwo = subCatagorizeDataTwo[indexPath.row] cell.businessName.text = tableObjects.nameString let charCheck = (tableObjects.address).replacingOccurrences(of: " ", with: "") print(charCheck) cell.businessName.text = " " var strings = "" strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.nameString+"[/b][b]" : "") strings = strings+(tableObjects.nameString.characters.count > 0 ? ""+tableObjects.address+"[/b][b]" : "") // strings = strings+(tableObjects.address.characters.count > 0 ? " [img]\[/img] "+tableObjects.address+" " : "") strings = strings+(tableObjects.telephone.characters.count > 0 ? " [img]\[/img] "+tableObjects.telephone+" " : "") strings = strings+(tableObjects.email.characters.count > 0 ? " [img]\[/img] "+tableObjects.email+" " : "") strings = strings+(tableObjects.website.characters.count > 0 ? " [img]\[/img] "+tableObjects.website : "") // cell.businessWebView.loadHTMLString(""+tableObjects.nameString+"[/b] [img]\[/img] "+tableObjects.address+" [img]\[/img] "+tableObjects.telephone+" [img]\[/img] "+tableObjects.email+" [img]\[/img] "+tableObjects.website, baseURL: nil) cell.businessWebView.loadHTMLString(strings, baseURL: nil) let heightIndex = strings.components(separatedBy: " ") let heightMul = heightIndex.count print(heightMul*32) self.heightOfTheCell = CGFloat(((heightMul)*32)+4) } return cell } else if indexPath.section == 1 { let cell = self.businessTableView.dequeueReusableCell(withIdentifier: "businessCell2") cell?.textLabel?.textAlignment = .center switch regId { case 0: if subCatagorizeDataTwo.count != forAll { cell?.textLabel?.text = "LOAD MORE DATA" cell?.textLabel?.textColor = Color.whiteColor cell?.backgroundColor = UIColor.darkGray }else{ cell?.textLabel?.text = "NO MORE FOUND!" cell?.textLabel?.textColor = UIColor.darkGray cell?.backgroundColor = UIColor.gray cell?.selectionStyle = UITableViewCellSelectionStyle.none } case 1: if subCatagorizeDataTwoN.count != forN { cell?.textLabel?.text = "LOAD MORE DATA" cell?.textLabel?.textColor = Color.whiteColor cell?.backgroundColor = UIColor.darkGray }else{ cell?.textLabel?.text = "NO MORE FOUND!" cell?.textLabel?.textColor = UIColor.darkGray cell?.backgroundColor = UIColor.gray cell?.selectionStyle = UITableViewCellSelectionStyle.none } case 2: if subCatagorizeDataTwoE.count != forE { cell?.textLabel?.text = "LOAD MORE DATA" cell?.textLabel?.textColor = Color.whiteColor cell?.backgroundColor = UIColor.darkGray }else{ cell?.textLabel?.text = "NO MORE FOUND!" cell?.textLabel?.textColor = UIColor.darkGray cell?.backgroundColor = UIColor.gray cell?.selectionStyle = UITableViewCellSelectionStyle.none } case 3: if subCatagorizeDataTwoS.count != forS { cell?.textLabel?.text = "LOAD MORE DATA" cell?.textLabel?.textColor = Color.whiteColor cell?.backgroundColor = UIColor.darkGray }else{ cell?.textLabel?.text = "NO MORE FOUND!" cell?.textLabel?.textColor = UIColor.darkGray cell?.backgroundColor = UIColor.gray cell?.selectionStyle = UITableViewCellSelectionStyle.none } case 4: if subCatagorizeDataTwoW.count != forW { cell?.textLabel?.text = "LOAD MORE DATA" cell?.textLabel?.textColor = Color.whiteColor cell?.backgroundColor = UIColor.darkGray }else{ cell?.textLabel?.text = "NO MORE FOUND!" cell?.textLabel?.textColor = UIColor.darkGray cell?.backgroundColor = UIColor.gray cell?.selectionStyle = UITableViewCellSelectionStyle.none } default:break } return cell! } else { let tableObjects:StorageSubCatagoriez3rd = SubCatagoriez3rd[indexPath.row] let cell = self.businessTableView.dequeueReusableCell(withIdentifier: "businessCell3") cell?.textLabel?.text = tableObjects.nameString return cell! } } [/code] Смотрите скриншот: [img]https://i.sstatic.net/xmHwS .png[/img] [img]https://i.sstatic.net/hNZm0.png[/img] И, как видно во втором Снимок экрана (Южный регион). Профиль должен был быть скрыт, поскольку он принадлежит Северному региону. Пожалуйста, дайте мне знать, как это исправить. Спасибо за время :) Модель: [code]class StorageSubCatagoriezTwo { var nameString:String var idString:String var address:String var telephone:String var email:String var website:String init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String) { self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) } } class StorageSubCatagoriezTwoNorth { var nameString:String var idString:String var address:String var telephone:String var email:String var website:String init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String) { self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) } } class StorageSubCatagoriezTwoEast { var nameString:String var idString:String var address:String var telephone:String var email:String var website:String init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String) { self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) } } class StorageSubCatagoriezTwoWest { var nameString:String var idString:String var address:String var telephone:String var email:String var website:String init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String) { self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) } } class StorageSubCatagoriezTwoSouth { var nameString:String var idString:String var address:String var telephone:String var email:String var website:String init(tempName:String,tempID:String,tempaddress:String,tempTelephone:String,tempEmail:String,tempWebsite:String) { self.nameString = tempName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.idString = tempID.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.address = tempaddress.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.telephone = tempTelephone.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.email = tempEmail.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) self.website = tempWebsite.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) } } [/code] Извлечение региона и присвоение переменной: [code]let id = String(describing: dictionary["id"]!) let name = String(describing: dictionary["BUSINESS_NAME"]!) let email = String(describing: dictionary["EMAIL"]!) var streetNo = String(describing: dictionary["STREET_NO"]!) var streetName = String(describing: dictionary["STREET_NAME"]!) var suburbID = String(describing: dictionary["SUBURB_ID"]!) var postCode = String(describing: dictionary["POSTCODE"]!) let regionID = String(describing: dictionary["REGION_ID"]!) var landline = String(describing: dictionary["PHONE_FIXED"]!) var mobile = String(describing: dictionary["PHONE_MOBILE"]!) let website = String(describing: dictionary["WEBURL"]!) var suburbName = String(describing: dictionary["Suburb"]!) let streedNoHide = String(describing: dictionary["STREET_NO_HIDDEN"]!) let streetNameHide = String(describing: dictionary["STREET_NAME_HIDDEN"]!) let suburbHide = String(describing: dictionary["SUBURB_HIDDEN"]!) let postCodeHide = String(describing: dictionary["POSTCODE_HIDDEN"]!) let mobileHide = String(describing: dictionary["PHONE_MOBILE_HIDDEN"]!) let landlineHide = String(describing: dictionary["PHONE_FIXED_HIDDEN"]!) [/code] ДАННЫЕ JSON: (REGION_ID) [img]https://i.sstatic.net /72Y2M.png[/img] Подробнее здесь: [url]https://stackoverflow.com/questions/45428922/swift-3-filtering-results-with-ids-and-reload-tableview[/url]