我正在尝试从 tableView 中删除重复项。表视图上获取的数据来自外部数据库。某些获取的数据会重复几次。
我需要显示的数据是配置文件名称和区域,即显示全部、北、东、南、西。现在,可以有一个配置文件(例如乔治的混凝土)可以出现在 3 个区域中。例如北、东、西。默认情况下,加载视图时,它会显示所有区域中的所有企业。就这样看来,我有一些业务是重复的。我们的 George 混凝土浇筑轮廓在此视图中重复 3 次,而它应该只重复一次。当我单击北/东/西时,乔治的混凝土也应该只出现一次。
所以基本上,George's Concreting 应该只在“全部显示”中出现一次,尽管它在 3 个区域有 3 个业务,并且当我们单击其他区域时,它也应该出现一次。请参考截图。
使用以下代码,我在网上得到并出错,请参阅错误
代码:
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)
}
}
___________________________________________________________
var subCatagorizeDataTwo = Array<StorageSubCatagoriezTwo>()
var subCatagorizeDataTwoN = Array<StorageSubCatagoriezTwoNorth>()
var subCatagorizeDataTwoE = Array<StorageSubCatagoriezTwoEast>()
var subCatagorizeDataTwoW = Array<StorageSubCatagoriezTwoWest>()
var subCatagorizeDataTwoS = Array<StorageSubCatagoriezTwoSouth>()
var SubCatagoriez3rd = Array<StorageSubCatagoriez3rd>()
func removeDuplicate (sourceArray: [Int]) -> [Int] {
var uniqueArray:[Int] = []
for object in sourceArray {
if !uniqueArray.contains(object)
{
uniqueArray.append(object)
}
}
return uniqueArray
}
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: "")
if reg == "North"
{
cell.businessName.text = " "
cell.addLabel.text = " "
cell.telLabel.text = " "
cell.emailLabel.text = " "
cell.webLabel.text = " "
var tableObjects:StorageSubCatagoriezTwoNorth = subCatagorizeDataTwoN[indexPath.row]
tableObjects = removeDuplicate(sourceArray: [tableObjects.nameString])
//**error** {Cannot convert value of type 'String' to expected element type 'Int'}
if tableObjects.address.characters.isEmpty != true
{
cell.addLabel.text = tableObjects.address
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
cell.telLabel.text = tableObjects.telephone
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
cell.emailLabel.text = tableObjects.email
}
else
{
}
if tableObjects.website.characters.isEmpty != true{
cell.webLabel.text = tableObjects.website
}
else{
}
}
else if reg == "East"
{
cell.businessName.text = " "
let tableObjects:StorageSubCatagoriezTwoEast = subCatagorizeDataTwoE[indexPath.row]
cell.businessName.text = tableObjects.nameString
if tableObjects.address.characters.isEmpty != true
{
cell.addLabel.text = tableObjects.address
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
cell.telLabel.text = tableObjects.telephone
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
cell.emailLabel.text = tableObjects.email
}
else
{
}
if tableObjects.website.characters.isEmpty != true
{
cell.webLabel.text = tableObjects.website
}
else{
}
}
else if reg == "South"
{
cell.businessName.text = " "
let tableObjects:StorageSubCatagoriezTwoSouth = subCatagorizeDataTwoS[indexPath.row]
cell.businessName.text = tableObjects.nameString
if tableObjects.address.characters.isEmpty != true
{
cell.addLabel.text = tableObjects.address
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
cell.telLabel.text = tableObjects.telephone
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
cell.emailLabel.text = tableObjects.email
}
else
{
}
if tableObjects.website.characters.isEmpty != true{
cell.webLabel.text = tableObjects.website
}
else{
}
}
else if reg == "West"
{
cell.businessName.text = " "
let tableObjects:StorageSubCatagoriezTwoWest = subCatagorizeDataTwoW[indexPath.row]
cell.businessName.text = tableObjects.nameString
if tableObjects.address.characters.isEmpty != true
{
cell.addLabel.text = tableObjects.address
}
else
{
//nothing
}
if tableObjects.telephone.characters.isEmpty != true
{
cell.telLabel.text = tableObjects.telephone
}
else
{
}
if tableObjects.email.characters.isEmpty != true
{
cell.emailLabel.text = tableObjects.email
}
else
{
}
if tableObjects.website.characters.isEmpty != true{
cell.webLabel.text = tableObjects.website
}
}
else{
let tableObjects:StorageSubCatagoriezTwo = subCatagorizeDataTwo[indexPath.row]
cell.businessName.text = tableObjects.nameString
let charCheck = (tableObjects.address).replacingOccurrences(of: " ", with: "")
cell.businessName.text = tableObjects.nameString
cell.addLabel.text = tableObjects.address
cell.telLabel.text = tableObjects.telephone
cell.emailLabel.text = tableObjects.email
cell.webLabel.text = tableObjects.website
}
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 Data 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 Data 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 Data 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 Data 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 Data 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!
}
}
解决方案: *(我只创建了4个函数)
func UpdateSubCatagorizeTwoRegNorth(_ id:String) {
subCatagorizeDataTwo.removeAll()
subCatagorizeDataTwoN.removeAll()
subCatagorizeDataTwoE.removeAll()
subCatagorizeDataTwoW.removeAll()
subCatagorizeDataTwoS.removeAll()
SubCatagoriez3rd.removeAll()
self.view.isUserInteractionEnabled = false
progress.isHidden = false
let request = NSMutableURLRequest(url: urls.subCatagoriezTwoURLRegNorth as URL)
let postString = "id="+id
request.httpBody = postString.data(using: String.Encoding.utf8)
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(with: request as URLRequest) { data,response,error in
guard error == nil && data != nil else
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("Error:\(error)", icon: "error", View: self)
return
}
let httpStatus = response as? HTTPURLResponse
if httpStatus!.statusCode == 200
{
if data?.count != 0
{
let responseString = convert.contvertToDictionary(data!) as? [[String:AnyObject]]
if responseString != nil
{
for dictionary in responseString!
{
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"]!)
let region = String(describing: dictionary["region"]!)
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"]!)
if streedNoHide != "0"
{
streetNo = ""
}else{
}
if streetNameHide != "0"
{
streetName=""
}
else{
//nothing here
}
if suburbHide != "0"
{
suburbName = ""
suburbID = ""
}
else{
//nothing here
}
if postCodeHide != "0"
{
postCode = ""
}
else{
//nothing here
}
if mobileHide != "0"
{
mobile = ""
}
else{
//nothing here
}
if landlineHide != "0"
{
landline = ""
}else
{
}
// streetno
DispatchQueue.main.async
{
if region == "North"
{
self.subCatagorizeDataTwoN.append(StorageSubCatagoriezTwoNorth(tempName: name, tempID: id, tempaddress: " "+streetNo+" "+streetName+" "+suburbName+" "+postCode, tempTelephone: landline+" "+mobile, tempEmail: email, tempWebsite: website))
}
self.subCatagorizeDataTwo.append(StorageSubCatagoriezTwo(tempName: name, tempID: id, tempaddress: " "+streetNo+" "+streetName+" "+suburbName+" "+postCode, tempTelephone: landline+" "+mobile, tempEmail: email, tempWebsite: website))
}
}
DispatchQueue.main.async
{
if self.subCatagorizeDataTwoN.count >= 10
{
self.forN = 10
}
else
{
self.forN = self.subCatagorizeDataTwoN.count
}
self.UpdateSubCatagorizeTwo1(self.catName, url: self.urls.XRef)
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("Problem with Requesting! Error 404", icon: "error", View: self)
}
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("No data got from url!", icon: "error", View: self)
}
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("error httpstatus code is : \(httpStatus!.statusCode)", icon: "error", View: self)
}
}
}
task.resume()
}
func UpdateSubCatagorizeTwoRegEast(_ id:String) {
subCatagorizeDataTwo.removeAll()
subCatagorizeDataTwoN.removeAll()
subCatagorizeDataTwoE.removeAll()
subCatagorizeDataTwoW.removeAll()
subCatagorizeDataTwoS.removeAll()
SubCatagoriez3rd.removeAll()
self.view.isUserInteractionEnabled = false
progress.isHidden = false
let request = NSMutableURLRequest(url: urls.subCatagoriezTwoURLEast as URL)
let postString = "id="+id
request.httpBody = postString.data(using: String.Encoding.utf8)
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(with: request as URLRequest) { data,response,error in
guard error == nil && data != nil else
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("Error:\(error)", icon: "error", View: self)
return
}
let httpStatus = response as? HTTPURLResponse
if httpStatus!.statusCode == 200
{
if data?.count != 0
{
let responseString = convert.contvertToDictionary(data!) as? [[String:AnyObject]]
if responseString != nil
{
for dictionary in responseString!
{
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"]!)
let region = String(describing: dictionary["region"]!)
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"]!)
if streedNoHide != "0"
{
streetNo = ""
}else{
}
if streetNameHide != "0"
{
streetName=""
}
else{
//nothing here
}
if suburbHide != "0"
{
suburbName = ""
suburbID = ""
}
else{
//nothing here
}
if postCodeHide != "0"
{
postCode = ""
}
else{
//nothing here
}
if mobileHide != "0"
{
mobile = ""
}
else{
//nothing here
}
if landlineHide != "0"
{
landline = ""
}else
{
}
// streetno
DispatchQueue.main.async
{
if region == "East"
{
self.subCatagorizeDataTwoE.append(StorageSubCatagoriezTwoEast(tempName: name, tempID: id, tempaddress: " "+streetNo+" "+streetName+" "+suburbName+" "+postCode, tempTelephone: landline+" "+mobile, tempEmail: email, tempWebsite: website))
}
self.subCatagorizeDataTwo.append(StorageSubCatagoriezTwo(tempName: name, tempID: id, tempaddress: " "+streetNo+" "+streetName+" "+suburbName+" "+postCode, tempTelephone: landline+" "+mobile, tempEmail: email, tempWebsite: website))
}
}
DispatchQueue.main.async
{
if self.subCatagorizeDataTwoE.count >= 10
{
self.forE = 10
}
else
{
self.forE = self.subCatagorizeDataTwoE.count
}
self.UpdateSubCatagorizeTwo1(self.catName, url: self.urls.XRef)
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("Problem with Requesting! Error 404", icon: "error", View: self)
}
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("No data got from url!", icon: "error", View: self)
}
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("error httpstatus code is : \(httpStatus!.statusCode)", icon: "error", View: self)
}
}
}
task.resume()
}
func UpdateSubCatagorizeTwoRegSouth(_ id:String) {
subCatagorizeDataTwo.removeAll()
subCatagorizeDataTwoN.removeAll()
subCatagorizeDataTwoE.removeAll()
subCatagorizeDataTwoW.removeAll()
subCatagorizeDataTwoS.removeAll()
SubCatagoriez3rd.removeAll()
self.view.isUserInteractionEnabled = false
progress.isHidden = false
let request = NSMutableURLRequest(url: urls.subCatagoriezTwoURLRegSouth as URL)
let postString = "id="+id
request.httpBody = postString.data(using: String.Encoding.utf8)
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(with: request as URLRequest) { data,response,error in
guard error == nil && data != nil else
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("Error:\(error)", icon: "error", View: self)
return
}
let httpStatus = response as? HTTPURLResponse
if httpStatus!.statusCode == 200
{
if data?.count != 0
{
let responseString = convert.contvertToDictionary(data!) as? [[String:AnyObject]]
if responseString != nil
{
for dictionary in responseString!
{
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"]!)
let region = String(describing: dictionary["region"]!)
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"]!)
if streedNoHide != "0"
{
streetNo = ""
}else{
}
if streetNameHide != "0"
{
streetName=""
}
else{
//nothing here
}
if suburbHide != "0"
{
suburbName = ""
suburbID = ""
}
else{
//nothing here
}
if postCodeHide != "0"
{
postCode = ""
}
else{
//nothing here
}
if mobileHide != "0"
{
mobile = ""
}
else{
//nothing here
}
if landlineHide != "0"
{
landline = ""
}else
{
}
// streetno
DispatchQueue.main.async
{
if region == "South"
{
self.subCatagorizeDataTwoS.append(StorageSubCatagoriezTwoSouth(tempName: name, tempID: id, tempaddress: " "+streetNo+" "+streetName+" "+suburbName+" "+postCode, tempTelephone: landline+" "+mobile, tempEmail: email, tempWebsite: website))
}
self.subCatagorizeDataTwo.append(StorageSubCatagoriezTwo(tempName: name, tempID: id, tempaddress: " "+streetNo+" "+streetName+" "+suburbName+" "+postCode, tempTelephone: landline+" "+mobile, tempEmail: email, tempWebsite: website))
}
}
DispatchQueue.main.async
{
if self.subCatagorizeDataTwoS.count >= 10
{
self.forS = 10
}
else
{
self.forS = self.subCatagorizeDataTwoS.count
}
self.UpdateSubCatagorizeTwo1(self.catName, url: self.urls.XRef)
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("Problem with Requesting! Error 404", icon: "error", View: self)
}
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("No data got from url!", icon: "error", View: self)
}
}
}
else
{
DispatchQueue.main.async
{
self.progress.isHidden = true
self.view.isUserInteractionEnabled = true
self.alertMessage.alert("error httpstatus code is : \(httpStatus!.statusCode)", icon: "error", View: self)
}
}
}
task.resume()
}
请对西部地区做同样的事情。并按要求更换。