Self-study secondiosapptutorial more than half, run the program error, the final problem to find, English documents read very frustrated, but patience can find the problem, Xcode's question is clear. As follows:
/*debug output error message, display TableView cell is null */*** terminating app due to uncaught exception ' Nsinternalinconsistencyexception ', Reason: ' UITableView dataSource must return a cell from Tableview:cellforrowatindexpath: '
The TableView has no return value and the cell value is null. The implementation of design TableView in MASTERVIEWCONTROLLER.M, start with the code to find the problem.
1 1-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath {2 2 /*UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:@ "cell" forindexpath:indexpath];3 34 4 NSDate *object = Self.objects[indexpath.row];5 5 Cell.textLabel.text = [object description];6 6 return cell;*/7 7 StaticNSString *cellidentifier =@"Birdsightingcell";/*Birdsightingcell is the identifier property name of the cell in the table.*/8 8 9 9 StaticNSDateFormatter *formatter =Nil;Ten Ten if(Formatter = =Nil) { One OneFormatter =[[NSDateFormatter alloc] init]; A A[Formatter setdatestyle:nsdateformattermediumstyle]; - - } - -UITableViewCell *cell =[TableView Dequeuereusablecellwithidentifier:cellidentifier]; the theNSLog (@"111222%@", cell); - -Birdsighting *sightingatindex =[Self.datacontroller ObjectInListAtIndex:indexPath.row]; - -[[Cell Textlabel] setText:sightingAtIndex.name]; - -[[Cell Detailtextlabel] settext:[formatter stringfromdate: (NSDate *) [sightingatindex.date]]; + +NSLog (@"111222%@", cell); - - returncell; + +}
Cell has no value, output information 15, 19 output is null. Then the 7th line is likely to go wrong. Birdsightingcell is the property value of cell identifier in TableView, and finds that its value in the table is actually a cell. Dawned. The exact location is as follows:
secondiosapptutorial--Study Notes