secondiosapptutorial--Study Notes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.