我通过alamofire打电话给api,我得到了完美的响应,我能够将所有数据都放入表格单元格中的标签中,但是有一个字段无法打印,请在下面解释一下
响应:
SUCCESS: {
data =(
{
"from_id" = 77;
"from_name" = Paresh;
image = "https://www.kwikmypay.com/mode_share/modeshare_admin/assets/images/business/userNotFound.png";
msg = hi;
"msg_date" = "18-07-2018 05:54:40 am";
"msg_id" = 1;
"new_msg" = 37;
"to_id" = 88;
"to_name" = Mihir;
}
从此响应中我可以打印所有内容,但是我无法打印一个字段“ new_msg”,任何人都可以解释一下这个问题,这是我的代码
let serviceparam = ["user_id":u_id,"access_token":acc_tkn,"time_zone": currentTimeZone] as [String : Any]
SVProgressHUD.show(withStatus: "Loading...")
Alamofire.request(chatList, method: .post, parameters: serviceparam).responseJSON
{
response in
print(response)
let result = response.result
if let dict = result.value as? Dictionary<String,AnyObject>{
if let serlist = dict["data"]{
self.servicelist = serlist as! [AnyObject]
self.tbl_chatlist.reloadData()
//self.dropDown.items = categorylist as! [AnyObject] as! [String]
}
}
SVProgressHUD.dismiss()
//self.activityIndicator.stopAnimating()
}
我的服务列表阵列已正确整理,我可以正确获取所有数据,但无法在标签上打印任何数据,请帮助我
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCell(withIdentifier: "chatlistcell") as! ChatlistTableViewCell
let f_name = servicelist[indexPath.row]["from_name"]
let image = servicelist[indexPath.row]["image"]
let date = servicelist[indexPath.row]["msg_date"]
let newMSG = servicelist[indexPath.row]["new_msg"]
let lastMsg = servicelist[indexPath.row]["msg"]
cell.lblTime.text = date as? String
cell.lblTitle.text = f_name as? String
cell.lblMsgCount.text = newMSG as? String
cell.lblLastMsg.text = lastMsg as? String
let proimgurl = NSURL(string: image as! String)
cell.img_logo.image = UIImage(data: NSData(contentsOf: proimgurl! as URL)! as Data)
return cell
}
这是代码,我有一个标签lblMsgCount,作为回应,有一个我无法打印的已提交的new_msg