Swift UITableView: How to Load data from JSON

后端 未结 3 662
一向
一向 2021-02-06 13:35

I am beginner in Swift and would like some help for my first application.I hope that I can explain it well. I am developing and app which is loading information from a JSON File

3条回答
  •  不思量自难忘°
    2021-02-06 14:12

    Try This it will Help you

     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
            {
                 let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell
    
            var dict = array[indexPath.row]
            cell.lbl1.text = dict["Name"] as? String
            cell.lbl2.text = dict["ad_created_date"] as? String
            cell.lbl3.text = dict["phone_number"] as? String
            cell.lbl4.text = dict["id"] as? String
            cell.lbl5.text = dict["ad_zip"] as? String
    
            let imageUrlString = dict["Picture"]
            let imageUrl:URL = URL(string: imageUrlString as! String)!
            let imageData:NSData = NSData(contentsOf: imageUrl)!
            cell.img.image = UIImage(data: imageData as Data)
    
    
    
            return cell
        }
    

提交回复
热议问题