2016-11-29 1 views
0

기본 tableview 설정이 있는데, JSON 데이터를로드합니다. 크래시 보고서에 패브릭을 사용 중입니다. 크래시를 복제하려고 시도했지만 충돌 보고서에서 시나리오를 추측 할 수있었습니다.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.yazar에서이 self.jsonData?[indexPath.row] (Bool)와 다른 유형 (Int)이다.

+0

내 셀의 yazar도 json입니다. 내 질문에 코드를 편집했습니다. –

+0

'self.jsonData? [indexPath.row]'를 로그 아웃하고'self.setupYazar()'에 대한 코드를 게시하십시오. – shallowThought

관련 문제