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 6805605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:36:24+00:00 2026-05-26T19:36:24+00:00

I’m programming my first iOS application and I’m trying to asynchronously load images into

  • 0

I’m programming my first iOS application and I’m trying to asynchronously load images into my UITableViewCells. I’m loading the images in the background into a NSMutableArray, which is then retrieved at the cellForRowAtIndexPath method. The cells are able to load the images, but crashes on the ~5th cell and gives me one of two different errors:

SIGABRT at the @synthesize line in ApplicationCell.m with malloc: * error for object 0x6c30e60: double free

or just enters gdb and points at iconView.image = newIcon; (Thread 1).

I’ve declared the NSMutableArray *imageArray in the @interface of the table view controller and set it as a @property, then @synthesize’d it:

@synthesize searchArray;
...
- (void)viewDidLoad {
    [super viewDidLoad];
    ...
    self.imageArray = [[NSMutableArray alloc] initWithCapacity:8]; //<-- Am I doing this correctly?
    for (int i=0; i < 8; i++) {
        [self.imageArray addObject:[UIImage imageNamed:@"empty.png"]];
    }
    ...
}

There will be a maximum of 8 images loaded in the background, which will be placed inside imageArray:

- (void)requestFinishedImage:(ASIFormDataRequest*)request {
    //image request
    NSData *responseData = [request responseData];
    NSIndexPath *index = [NSIndexPath indexPathForRow:request.tag inSection:0];
    UIImage *image = [[UIImage alloc] initWithData:responseData];
    NSLog(@"requested Image with tag: %d",request.tag);
    [imageArray replaceObjectAtIndex:request.tag withObject:image];
    ApplicationCell *cell = (ApplicationCell *)[self.tableView cellForRowAtIndexPath:index];
    [cell setIcon2:image];
    cell.icon = image;
    [image release];
}

Here is the cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    ApplicationCell *cell = (ApplicationCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        [self.cellNib instantiateWithOwner:self options:nil];
        cell = tmpCell;
        self.tmpCell = nil;
    }
    UIImage *image;
    NSUInteger row = [indexPath row];

    [cell setItem2: [[searchArray objectAtIndex:row] objectForKey:@"item"]];
    [cell setPrice2: cell.price];
    image = [imageArray objectAtIndex:row];
    NSLog(@"num elements in imageArray = %d, loading: %d",[imageArray count], row);
    [cell setIcon2: image];
[image release];
    return cell;
}

And here are my ApplicationCell.h and ApplicationCell.m

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface ApplicationCell : UITableViewCell
{

    UIImage *icon;
    NSString *item;
    NSString *price;
    IBOutlet UIImageView *iconView;
    IBOutlet UILabel *itemLabel;
    IBOutlet UILabel *priceLabel;
}
- (void)setIcon2:(UIImage *)newIcon;
- (void)setItem2:(NSString *)newItem;
- (void)setPrice2:(NSString *)newPrice;

@property(retain) UIImage *icon;
@property(retain) NSString *item;
@property(retain) NSString *price;

@end

ApplicationCell.m

#import "ApplicationCell.h"

@implementation ApplicationCell

@synthesize icon, item, price;

- (void)setIcon2:(UIImage *)newIcon
{
    [self setIcon:newIcon];
    iconView.opaque = YES;
    iconView.image = newIcon;
}
- (void)setItem2:(NSString *)newItem
{
    [self setItem:newItem];
    itemLabel.text = newItem;
}

- (void)setPrice2:(NSString *)newPrice
{
    [self setPrice:newPrice];
    priceLabel.text = newPrice;
}


- (void)dealloc
{
    [icon release];
    [item release];
    [price release];

    [iconView release];
    [itemLabel release];
    [priceLabel release];

    [super dealloc];
}

@end

There are probably some mistakes in the code since this is my first time trying an iOS application, but please let me know so I can learn! I’ve been stuck on this async loading issue for too long.. Any help is appreciated!

  • 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-26T19:36:25+00:00Added an answer on May 26, 2026 at 7:36 pm

    Take out the [image release] call in -tableView:cellForRowAtIndexPath:. You didn’t retain it there,so you don’t need to release it. If you use Xcode’s static analyzer, it should find memory errors like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

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.