gpt4 book ai didi

swift - TableView EXC_BREAKPOINT 崩溃

转载 作者:行者123 更新时间:2023-11-30 12:51:45 30 4
gpt4 key购买 nike

我有一个基本的 tableview 设置,用于加载 JSON 数据。我正在使用 Fabric 进行崩溃报告,我尝试复制崩溃,但我可以从崩溃报告中猜测场景。

override func viewDidLoad() {
let id = newID
API.sharedInstance.loadList(id, callback: { (list) in
if let data = list["objects"].arrayValue as [JSON]?{
self.jsonData = data
self.tableView.reloadData()
self.refreshControl?.endRefreshing()
self.loadingView?.removeFromSuperview()
}
})
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.jsonData?.count ?? 0
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as! CustomTableViewCell
cell.yazar = self.jsonData?[indexPath.row]
return cell
}

崩溃报告:

 #0. Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x10111e588 specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt) -> () + 44
1 libswiftCore.dylib 0x100ff7654 specialized _ArrayBuffer.getElement(Int, wasNativeTypeChecked : Bool) -> A + 270
2 libswiftCore.dylib 0x10100db30 Array.subscript.getter + 112
3 yazar.io 0x10021c4d0 GazetininYazarlariTableViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell (CustomViewController.swift:290)

编辑:在我的表格 View 单元中

var yazar:JSON?{
didSet{
self.setupYazar()
}
}

最佳答案

cell.yazar 的类型 (Int) 与 self.jsonData?[indexPath.row] (Bool )。

关于swift - TableView EXC_BREAKPOINT 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40875015/

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