swift - tableview EXC_BREAKPOINT崩溃

时间:2016-11-29 20:15:28

标签: swift tableview

我有一个基本的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)

编辑:在我的tableviewcell中

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

1 个答案:

答案 0 :(得分:0)

cell.yazar属于不同类型(Int),而不是self.jsonData?[indexPath.row]Bool)。

相关问题