2016-11-29 166 views
0

我有一個基本的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() 
     } 
} 

回答

0

cell.yazarself.jsonData?[indexPath.row]Bool)不同類型(Int)的。

+0

yazar在我的手機也是json。在我的問題中編輯了代碼。 –

+0

請註銷'self.jsonData?[indexPath.row]'併發布代碼'self.setupYazar()' – shallowThought