swift - tableview EXC_BREAKPOINT崩溃
问题描述:
我有一个基本的tableview
设置,我加载JSON数据。 我使用Fabric进行崩溃报告,我试图复制崩溃,但我可以从崩溃报告中猜测场景。swift - tableview EXC_BREAKPOINT崩溃
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)
编辑:在我的tableviewcell
var yazar:JSON?{
didSet{
self.setupYazar()
}
}
答
cell.yazar
比self.jsonData?[indexPath.row]
(Bool
)不同类型(Int
)的。
yazar在我的手机也是json。在我的问题中编辑了代码。 –
请注销'self.jsonData?[indexPath.row]'并发布代码'self.setupYazar()' – shallowThought