I put message “no results” when my tableview is empty.
the problem is that when I have 1 row and I want to delete this row number of rows
don’t change because I have if condition that show me “no results” use row,
I can make bool property that check if deleted and then if user delete this row that will not show him message “no results”, but maybe someone have better way?
my methods:
num of sections:
if([[[self fetchResultsController] fetchedObjects] count] == 0)
return 1;
rows in section:
if([[[self fetchResultsController] fetchedObjects] count] == 0)
return 1;
cell:
if([[[self fetchResultsController] fetchedObjects] count] == 0){
[[cell textLabel] setText:@"no results"];
}else{ //create regular or from search cell.
The best solution that I find is make a title instead of cell to avoid problems with delete and update (core data). but title as I know can’t appear if there no rows or sections. So I solute it with this two methods:
I put this one named show at the num_of_sections..:
this method works well when delete rows.
the second method named hide I use when I create new row (I put the method in my “save method”) this method delete the title.
edit:
another way:
As I try before num of row…
change cell too:
the issue id a delete row so I use bool to avoid crush at
didLoad method bool = 0;when I
delete I insert 1 to the booldon’t forget cancel the delete option for this cell!!the problem with this solution that it’s not perfect, when I delete the last row my tableView is empty only when I load table again the title appear that not what I want.
If someone have more elegant solution please tell me I promise check your answer as correct answer.