gpt4 book ai didi

Swift 3 在解包 Optional 值时意外发现 nil

转载 作者:行者123 更新时间:2023-11-28 10:54:01 25 4
gpt4 key购买 nike

<分区>

每当我尝试从 firebase 获取数据时,都会发生这种情况

enter image description here

这是我的代码

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 返回 1

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: self.postCell, for: indexPath) as! PostCell

cell.postedImage.downloadImageUrl(from: setPost[indexPath.section].userPostImage)
cell.postItemPriceLabel.text = setPost[indexPath.section].userPriceTag
cell.selectionStyle = .none

return cell
}

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: self.headerCell) as! HeaderCell
cell.profileImage.downloadImageUrl(from: setPost[section].userphoto)
cell.fullname.text = setPost[section].fullname
cell.backgroundColor = UIColor.white
return cell
}


extension UIImageView {
func downloadImageUrl(from imgUrl: String!){

let url = URLRequest(url: URL(string: imgUrl)!)

let session = URLSession.shared

session.dataTask(with: url){
(data, response, err) in

if err != nil {
print(err!)
return
}
DispatchQueue.main.async {
self.image = UIImage(data: data!)
}
}.resume()

请有人帮帮我

谢谢

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com