ios - 线程 1:在 TableView Swift 上重新加载数据时,在 AppDelegate 上发出 SIGABRT 信号
问题描述
我正在使用自定义单元格填充 tableView。我从元组数组中获取单元格标签文本和 imageView 图像,(String:String)
其中第一个值是商店名称,第二个值是存储在 firebase 存储中的图像的 Url。在我对 firebase 的查询结束时,我得到了availableShopsArray
填充并重新加载 tableView 的数据。在cellForRowAt
函数中,我将元组的两个参数分配给单元格标签和图像。但是在重新加载数据时,我在 AppDelegate 中遇到错误。
这是我声明函数的方式:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "shopCell", for: indexPath as IndexPath) as! ShopTableViewCell
cell.shopNameLabel.text = self.availableShopsArray[indexPath.row].0
let url = URL(string: self.availableShopsArray[indexPath.row].1)
let data = try? Data(contentsOf: url!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
cell.imageView?.image = UIImage(data:data!)
return cell
}
这是我的单元格:
import UIKit
class ShopTableViewCell: UITableViewCell {
@IBOutlet weak var makerImageView: UIImageView!
@IBOutlet weak var shopImageView: UIImageView!
@IBOutlet weak var shopNameLabel: UILabel!
@IBOutlet weak var shopRatingLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
任何想法
解决方案
我要做的第一件事是创建一个异常来尝试查找错误的位置,这是一个关于如何做到这一点的有用教程:https ://mukeshthawani.com/debug-the-sigabrt-error-exception
推荐阅读
- javascript - 如何在验证器函数中使用 JS 提交表单
- esp8266 - ESP8266 OTA 更新使用新的 wifi 密码
- c# - 解压和压缩回不返回相同的内容
- string - sed 删除除匹配模式之外的所有行
- java - 尝试在 Java 中添加数字时擦除 txt 文件中的数据
- javascript - jQuery 的 .click() 方法是否适用于 Bootstrap Star Rating
- javascript - iframe responsive:如果窗口 iframe 的大小内容发生变化?
- r - 如果一对值在列表列表中,则过滤数据框
- java - 尽管已初始化,Firebase 仍会引发未初始化的错误
- javascript - react firebase中的“admin.firestore.collection不是函数”-如何传递启动的管理对象?