The following is the code I am using to display image in the table view and its name. It works fine however when we have lot of images inside the folder the app crashes. Any help is greatly appreciated.
NSString *CellIdentifier = @"DocumentList";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *bundleRoot = [paths objectAtIndex:0];
NSString *dataPath = [bundleRoot stringByAppendingPathComponent:[NSString stringWithFormat:@"%d", 1]];
NSString *imagePath = [NSString stringWithFormat:@"%@/%@", dataPath, [itsDocumentNamesArray objectAtIndex:indexPath.row]];
[cell.imageView setImage:[[[UIImage alloc] initWithContentsOfFile:imagePath] autorelease]];
cell.textLabel.text = [itsDocumentNamesArray objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:15.0];
cell.textLabel.textColor = [UIColor grayColor];