Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6836253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:20:02+00:00 2026-05-26T23:20:02+00:00

I update the table view cell using the method below: – (void)imageDownloader:(SDWebImageDownloader *)downloader didFinishWithIndexPath:(NSIndexPath

  • 0

I update the table view cell using the method below:


- (void)imageDownloader:(SDWebImageDownloader *)downloader didFinishWithIndexPath:(NSIndexPath *)indexPath
{
    NSArray *arr = [self.tableView indexPathsForVisibleRows];
    if ([arr containsObject:indexPath]) 
    {
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];//received error here
        UIImageView *imageView = (UIImageView *)[cell viewWithTag:'ICON'];
        SDWebImageManager *manager = [SDWebImageManager sharedManager];
        UIImage *image = [manager imageWithURL:downloader.url];
        imageView.image = image;
    }
}

This is a delegate of SDWebImageDownloader and received error when update:

thread9:  Program received signal: "SIGABRT".

Form the device console, there is:

: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 7 beyond bounds [0 .. 6]'
    *** First throw call stack:
    (0x335a38bf 0x300971e5 0x334ecb6b 0x30ff0eb1 0xaa0a7 0x334fd435 0xb5b13 0x30d91a91 0x30e255a1 0x36fa0c1d 0x36fa0ad8)

Then I print the arr which holds the current visible index path:

Printing description of arr:
(
    " 2 indexes [0, 1]",
    " 2 indexes [0, 2]",
    " 2 indexes [0, 3]",
    " 2 indexes [0, 4]",
    " 2 indexes [0, 5]",
    " 2 indexes [0, 6]",
    " 2 indexes [0, 7]"
)

and the received indexPath

 2 indexes [0, 7]

The indexPath is included in the visible index path, and why it still cause the NSRangeException?
It looks like a bug for cellForRowAtIndexPath:indexPath, as the row of index path is 7 which is beyond the visible index path arr, am I right?

Add the eatableview delegate method:


- (UITableViewCell *)tableView:(UITableView *)inTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    NSString *path;
    NSString *filename;

    BOOL download = YES;
    NSDictionary *tempDic = nil;
    @synchronized (documentDirectoryFileList) {
        tempDic = [self.documentDirectoryFileList objectAtIndex:indexPath.row];
        filename = [tempDic objectForKey:@"filename" ];

        NSURL *url = [tempDic objectForKey:@"url" ];
        if ( url ) {
            path = [ url path ];
            download= [ self downloadedFile:url ];

        } else {

                path = [tempDic objectForKey:@"filepath" ];
        }
    }

    BOOL isDirectory = FALSE;

    NSFileManager *fileManager = [[NSFileManager alloc] init];
    BOOL found = [fileManager fileExistsAtPath: path isDirectory: &isDirectory];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        CGRect rect;
        rect = CGRectMake(5,14, 32, 32);

        cell.userInteractionEnabled = YES;

        UIImageView *imageView = [[UIImageView alloc] initWithFrame:rect];
        imageView.tag = 'ICON';
        [cell.contentView addSubview:imageView];
        [imageView release];        

        rect = CGRectMake(42, 10, 238, 22);

        UILabel *labelView = [[UILabel alloc] initWithFrame:rect];
        labelView.tag = 'NAME';
        labelView.font = [UIFont boldSystemFontOfSize:18];
        if ( download == NO )
            labelView.textColor = [UIColor lightGrayColor ];
         [cell.contentView addSubview:labelView];
        [labelView release];

        rect = CGRectMake(42, 34, 200, 20);
        labelView = [[UILabel alloc] initWithFrame:rect];
        labelView.tag = 'TIME';
        labelView.font = [UIFont systemFontOfSize:12];
        if ( download == NO )
            labelView.textColor = [UIColor lightGrayColor ];
        [cell.contentView addSubview:labelView];
        [labelView release];

        rect = CGRectMake(200, 34, 75, 20);
        labelView = [[UILabel alloc] initWithFrame:rect];
        labelView.tag = 'SIZE';
        labelView.font = [UIFont systemFontOfSize:12];
        if ( download == NO )
            labelView.textColor = [UIColor lightGrayColor ];
        labelView.textAlignment = UITextAlignmentRight;
        [cell.contentView addSubview:labelView];
        [labelView release];

    }


    // Get the time zone wrapper for the row
    UIImageView *imageView = (UIImageView *)[cell viewWithTag:'ICON'];
    imageView.image = NULL;

    NSString* extension = [[path pathExtension] lowercaseString];
    if ([extension isEqualToString: @"png"] ||
        [extension isEqualToString: @"jpg"] ||
        [extension isEqualToString: @"jpeg"] ||
        [extension isEqualToString: @"bmp"] ||
        [extension isEqualToString: @"gif"] ||
        [extension isEqualToString: @"tiff"] ||
        [extension isEqualToString: @"thm"])
    {
        NSString *realFilePath = [ fileManager destinationOfSymbolicLinkAtPath:path error:nil ];
        if ( realFilePath )
            path = realFilePath;

        NSURL *url = [[NSURL fileURLWithPath:path] URLByAppendingPathComponent:@"thumb.th"];
        SDWebImageManager *manager = [SDWebImageManager sharedManager];
        UIImage *temp = [manager imageWithURL:url];
        if (temp) {
            imageView.image = temp;
        }
        else
        {
            SDWebImageDownloader *downloader = [SDWebImageDownloader downloaderWithURL:url delegate:self indexPath:indexPath];
        }

    } else {

        imageView.image = [ self determineFileIcon : path ];

    }

    // Configure the cell.
    UILabel *labelView = (UILabel *)[cell viewWithTag:'NAME'];
    labelView.text = filename;
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    if ( isDirectory ) {
        if ( isLink( path ) )
            labelView.font = [UIFont italicSystemFontOfSize:16.0];
        else
            labelView.font = [UIFont boldSystemFontOfSize:16.0];
    } else {
        if ( isLink( path ) )
            labelView.font = [UIFont italicSystemFontOfSize:16.0];
        else
            labelView.font = [UIFont systemFontOfSize:16.0];
    }

    labelView = (UILabel *)[cell viewWithTag:'TIME'];
    NSCalendar *theCalendar= [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSCalendarUnit unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;

    NSDate *date = [tempDic objectForKey:@"date" ];
    NSDateComponents *dateComponents = [theCalendar components:unitFlags fromDate:date];

    NSInteger year = [dateComponents year];
    NSInteger month = [dateComponents month];
    NSInteger day = [dateComponents day];
    NSInteger hour = [dateComponents hour];
    NSInteger minute = [dateComponents minute];
    NSInteger second = [dateComponents second];

    [theCalendar release];
    labelView.text = [NSString stringWithFormat:@"%d/%02d/%02d %02d:%02d:%02d", year,month,day,hour,minute,second ];

    if ( !isDirectory ) {
        labelView = (UILabel *)[cell viewWithTag:'SIZE'];
        [labelView setHidden:NO];
        NSNumber *size = [tempDic objectForKey:@"filesize" ];
        float value = [ size floatValue ];
        NSString *str;
        if ( value > ( 1024*1024 ) ) {
            value = value / 1024 / 1024;
            str = [NSString stringWithFormat:@"%0.1f MB", value ];
        } else if ( value > 1024 ) {
            value = value / 1024;
            str = [NSString stringWithFormat:@"%0.1f KB", value ];
        } else {
            str = [NSString stringWithFormat:@"%d Bytes", [ size integerValue ] ];
        }
        labelView.text = str;
    }
    else
    {
        labelView = (UILabel *)[cell viewWithTag:'SIZE'];
        [labelView setHidden:YES];
    }

    [fileManager release];

    return cell;
}

Added on 11-17:
when the “SIGABRT” receives, the documentDirectoryFileList has the objects, for example 30+. The received indexPath is existed in the visible index path array. But I noticed that: it is easy to happen when I scroll the tableview. There is no new object added to the datasource. what I do is just updating the image on the cell.

I guess it maybe:
when the received index path begin to update the corresponding cell, I happen to scroll it and the cell or the indexpath is no longer visible. And then it crashes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:20:03+00:00Added an answer on May 26, 2026 at 11:20 pm

    It seems a kind of problem about multithread.

    
    - (void)imageDownloader:(SDWebImageDownloader *)downloader didFinishWithIndexPath:(NSIndexPath *)indexPath
    {
    
    
        @synchronized(tableView)
        {
            NSArray *arr = [self.tableView indexPathsForVisibleRows];
            if ([arr containsObject:indexPath]) 
            {
    
                UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
                if (!cell) 
                {
                    return;
                }
    
                UIImageView *imageView = (UIImageView *)[cell viewWithTag:'ICON'];
                SDWebImageManager *manager = [SDWebImageManager sharedManager];
                UIImage *image = [manager imageWithURL:downloader.url];
                if (image) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        imageView.image = image;
                    });
    
                }
            }
    
        }
    }
    

    or you can

    
    - (void)imageDownloader:(SDWebImageDownloader *)downloader didFinishWithIndexPath:(NSIndexPath *)indexPath
    {
    
    
        @synchronized(tableView)
        {
            NSArray *arr = [self.tableView indexPathsForVisibleRows];
            if ([arr containsObject:indexPath]) 
            {
    
                dispatch_async(dispatch_get_main_queue(), ^{
                        [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
                    });//must be in main thread; reloadRowsAtIndexPaths: is not thread safe
    
    
    
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Table View Controller with cells. I want to update the text
when i update a table using hibernate getHibernateTemplate().bulkUpdate(UPDATE Channel SET number = 40 AND
I have 2 image view on a single table view cell. and i am
A simple stupid UPDATE table SET something=another WHERE (always true) in accident will easily
I am trying to update table A with data from table B. I thought
When you run something similar to: UPDATE table SET datetime = NOW(); on a
I want to update a table to indicate that some rows are parents of
string selectSql = update + table + set state_ + mode + _id=1 WHERE
Update : Unfortunately the help offered below did not solve my problem of sharing
So you have UINavigationController, with a parent table which has one cell --------------- |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.