Hi, My problem seems quite simple but I have failed to find a solution here or elsewhere. I have a UITableView as a subclass in one of my UIViews. When the application finishes the last selected table cell is saved to NSUserDefaults and when the aplication restarts I want to set the seleced cell as it was before. However, this causes problems when I do it too early as the number of sections are unknown, ie the table hasn't loaded its data yet. So I decided to set it in the function numberOfRowsInSection, which works but I am sure is not the correct place to do this. Any help would be much appreciated.
Blockquote
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { int iNofRows = 0; //Default
// It is not great doing this here but.... if(bSetDefaultSelection == YES)
{
bSetDefaultSelection = NO; // Stop recursion
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:(NSUInteger)l last_sel_row inSection:(NSUInteger)0];
[self selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
}
return iNofRows;
}