안녕 UITableViewCell
안에 UITableview
을 추가하려고합니다. I는 정의 셀 클래스 뷰 컨트롤러 (셀 내부) 내부의 TableView에 외부의 tableview 셀을 접속로드 테이블 뷰 uitableviewcell 내부 스위프트
//cellforrow of the outer tableview:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCellWithIdentifier("HistoryCell")! as! OrderHistoryTableViewCell
print(ordersArray[indexPath.row].valueForKey("items"))
cell.lbl_orderStatus.text = ordersArray[indexPath.row].valueForKey("status") as? String
cell.lbl_time.text = ordersArray[indexPath.row].valueForKey("timestamp") as? String
let vc = OrderHistoryTableViewCell() // Custom cell class
vc.tableview_reload(ordersArray[indexPath.row]as! NSMutableDictionary) //pass value to the tableview inside the cell
return cell
}
//code in the custom cell class
func tableview_reload(dict : NSMutableDictionary){
orderItemsarray.removeAllObjects()
let itemsDict = dict.valueForKey("items") as! NSMutableDictionary
for (_,value) in itemsDict
{
let tempDict = value as! NSMutableDictionary
orderItemsarray.addObject(tempDict)
}
self.tbl_Items.reloadData() // fatal error: unexpectedly found nil while unwrapping an optional value
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return self.orderItemsarray.count;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
var cell : UITableViewCell!
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cell");
cell.textLabel?.text = "test"
return cell
}
데이터가 전달되는 다음 코드 및 사용자 지정 셀 클래스의 FUNC의 tableview_reload을 수행했다 호출됩니다. 내가 정의 셀 클래스 치명적인 오류에서의 tableview를 다시로드하려고 할 때 :
unexpectedly found nil while unwrapping a optional value occurs.
나는 출구 연결을 확인했고 그것은 사용자 정의 셀 클래스에 연결되어 있습니다. 대신 당신이 dequeueReusableCellWithIdentifier
를 사용하여 만든 재사용 셀을 사용할 필요가 OrderHistoryTableViewCell()
를 사용하여 새로운 인스턴스를 생성하는
은'tbl_Items' 전에이라고 다시로드 – Tj3n
확인 콘센트가'tbl_Items'가 제대로 연결되어 인쇄 해보십시오. Tj3n의 포 tel_Items @ –
이 (lldb) 포 tbl_Items 치명적인 오류를 제공합니다 : 예기치 않게하는 옵션 값을 치명적인 오류를 풀기 동안 nil을 발견 표현 생산 오류 (선택 사양) 값을 풀기 동안 예기치 않게 전무을 발견 : 실행이 중단 된 이유 : EXC_BAD_INSTRUCTION를 (코드 = EXC_I386_INVOP, 서브 코드 = 0x0). 프로세스가 표현식 평가 이전 상태로 리턴되었습니다. – Mohanraj