我存储了如下数据: -
视图模型: -
typealias dummyDataSource1 = QM_RestaurtantDataSourceModel
extension dummyDataSource1{
func getJsonDataStored1() ->Array<Dictionary<String,String>>{
let jsonArray = [["name":"Anjapar","imageurl":"https://www.planwallpaper.com/static/images/9-credit-1.jpg","city":"Musheireb,Qatar"],["name":"Aryaas","imageurl":"https://www.planwallpaper.com/static/images/9-credit-1.jpg","city":"Al Muntazah,Qatar"],["name":"India Coffee","imageurl":"","city":"Doha,Qatar"],["name":"Saravana","imageurl":"https://www.planwallpaper.com/static/images/9-credit-1.jpg","city":"Al Muntazah,Qatar"],["name":"Tea Time","imageurl":"","city":"Old Airport,Qatar"]] as Array<Dictionary<String,String>>
return jsonArray
}
我需要在UIImgeView中显示imageurl:-image。如何做 我尝试使用代码: -
@IBOutlet weak var name: UILabel!
@IBOutlet weak var city: UILabel!
@IBOutlet weak var imageurl: UILabel!
@IBOutlet weak var images: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
func setRestaurtantData(restaurtant:QM_RestaurtantModel)
{
self.name.text = restaurtant.name
self.city.text = restaurtant.city
self.imageurl.text = restaurtant.imageurl
}
我的模特: -
var name:String! var city:String! var imageurl:String!
init?(dictionary :JSONDictionary) {
guard let name = dictionary["name"] as? String,
let imageurl = dictionary["imageurl"] as? String,
let city = dictionary["city"] as? String else {
return
}
self.name = name
self.city = city
self.imageurl = imageurl
}
我将值作为字符串,但我需要显示图像