我正在设置UITableview
的部分。我创建的numberofrowinsection
取决于JSON数据计数。现在,我要设置已退出部分中的另一部分?
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if (section == 0) {
return ""
}
else if(section == 1 ) { //&& self.contactFormResponse.count>0
return ""
}
else if section == numberOfSections-1 {
if isMSDivPrtyChecking == true {
//dictionary key title after hit server
}
else {
return ""
}
}
//multishare
else if (section == numberOfSections-2){
return ""
}
else if(section == numberOfSections-3){ //1
return ""
}
JSON: {
"statusCode": 200,
"statusMessage": "success",
"response": {
"data": {
"Div 1": [
{
"ID": "6",
"Value": "H1",
},
{
"ID": "7",
"Value": "L1",
},
{
"ID": "20",
"Value": "ManageP1",
},
{
"ID": "21",
"Value": "ManagerP2",
}
],
"Div2": [
{
"ID": "10",
"Value": "Cool"
},
{
"ID": "11",
"Value": "Warm"
}
]
}
}}
fileprivate var msDivPrtySection = Array<DivPrioritySection>()
我在代码下方实现了JSON响应:
if let Streams = responseDict["response"] as? [String:AnyObject]
{
let dictArrayDict = Streams["data"] as! Dictionary<String,AnyObject>
//as? [String:AnyObject] {
self.divPrityRowsCount = dictArrayDict.count
for (key, value) in dictArrayDict {
let users = DivPrioritySection(divisionName: key, data: value as! Array<Dictionary<String, String>>)
self.msDivPrtySection.append(users)
}
在这里,我在表格视图Total numberOfSections = 5
中安顿下来,当我点击服务器时,isMSDivPrtyChecking
将在上面的JSON中返回字典数组。我想在
else if section == numberOfSections-1 {
if isMSDivPrtyChecking == true {
// Here displaying JSON arrayOfDictionary title (dictionary key names)
}
我根据json数据计数创建了numberofrowinsection
,还通过JSON单个DIV1,DIV2等对按钮操作进行了下拉。