It takes too much time on [_fetchedResultsController objectAtIndexPath:indexPath]
, is there any alternative way ? heightForRowAtIndexPath takes too much time on this point. I don't know this is wrong question or not, but please help me to get the proper solution.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
ThreadInfo *info=[_fetchedResultsController objectAtIndexPath:indexPath];
NSString* objectId = info.threadID;
if (![self.idToCellHeight objectForKey: objectId])
{
CGFloat height = [self calculateHeightForId:info];
[self.idToCellHeight setObject:[NSNumber numberWithFloat:height] forKey: objectId];
}
return [[self.idToCellHeight objectForKey:objectId] floatValue];
}
The alternative way is to use self-sizing cells. You won't have to calculate (or cache) any row heights.
self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 44.0;
For more information, see the detailed walkthrough by smileyborg in his answer to Using Auto Layout in UITableView for dynamic cell layouts & variable row heights.