iosobjective-cuitableviewcore-datauikit

UITableView full of CoreData results plus additional cell?


I have a UITableView which I fill with CoreData fetched results. I want to add an single custom cell to the top of my UITableView and have managed to do so, however it requires me to have to call this:

return [sectionInfo numberOfObjects] + 1;

Then this:

NSIndexPath *path = [NSIndexPath indexPathForRow:(indexPath.row - 1) inSection:indexPath.section];

The second line has to be called in almost all of the UITableView Delegate methods to account for the additional cell at indexPath 0. However it causing a ton of problems which I won't list as every time i make changes here and there whatever it may be this is the root of my problem.

Is there any other method you would suggest to simply add my single custom cell to the top of my CoreData tableview?


Solution

  • If you are using this extra cell as a header, consider setting the tableView.tableHeaderView to a custom view.