SecondiosAppTutorial -- learning notes, learning notes app
I learned SecondiosAppTutorial more than half. When I run the program, I reported an error and finally found the problem. I was frustrated when I read the English document, but I was patient enough to find the problem. The prompt for Xcode was clear. As follows:
/* Debug output error message. TableView cell is null */*** Terminating app due to uncaught exception 'nsinternalinconsistencyexception', reason: 'uitableview dataSource must return a cell from tableView: cellForRowAtIndexPath :'
TableView has no return value, and the cell value is null. Design the implementation of TableView in MasterViewController. m, first from the code to find the problem.
1-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {2 2/* UITableViewCell * cell = [tableView progress: @ "Cell" forIndexPath: indexPath]; 3 3 4 4 4 NSDate * object = self. objects [indexPath. row]; 5 5 cell. textLabel. text = [object description]; 6 6 return cell; */7 7 static NSString * CellIdentifier = @ "BirdSightingCell "; /* BirdSightingCell is the Identifier attribute name of the cell in the table */8 8 9 9 static NSDateFormatter * formatter = nil; 10 10 10 if (formatter = nil) {11 11 formatter = [[NSDateFormatter alloc] init]; 12 12 [formatter setDateStyle: NSDateFormatterMediumStyle]; 13 13} 14 14 UITableViewCell * cell = [tableView identifier: CellIdentifier]; 15 15 NSLog (@ "111222% @", cell); 16 16 BirdSighting * sightingAtIndex = [self. dataController objectInListAtIndex: indexPath. row]; 17 17 [[cell textLabel] setText: sightingAtIndex. name]; 18 18 [[cell detailTextLabel] setText: [formatter stringFromDate :( NSDate *) sightingAtIndex. date]; 19 19 NSLog (@ "111222% @", cell); 20 20 return cell; 21 21 21}
Cell has no value. output information 15 and 19 are all null. Therefore, 7th rows may have errors. BirdSightingCell is the value of cell Identifier in TableView. It turns out that the value in the table is cell. Suddenly realized. The specific location is as follows: