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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:11:22+00:00 2026-06-13T02:11:22+00:00

After two days searching this answer I found a solution. Use GCD for download

  • 0

After two days searching this answer I found a solution.

  • Use GCD for download images asynchronously.
  • Use NSMutableDictionary for save images in memory.

I found the solution explained here by Duncan C:

http://iphonedevsdk.com/forum/iphone-sdk-development/104438-grand-central-dispatch-tableview-images-from-the-web.html

How to implement:

- (void)viewDidLoad
{
(...)
dispatch_queue_t mainQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

imagesDictionary = [[NSMutableDictionary alloc] init];
  (...)
}

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

NSData *imageData = [imagesDictionary objectForKey:@"IMAGE URL"];

    if (imageData)
    {
        UIImage* image = [[UIImage alloc] initWithData:imageData];

        imageFlag.image = image;
        NSLog(@" Reatriving ImageData...: %@", @"IMAGE URL");


    }
    else
    {

    dispatch_async(mainQueue, ^(void) {

        NSString *url = @"IMAGE URL";
        NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:url]];
        UIImage* image = [[UIImage alloc] initWithData:imageData];

        imageFlag.image = image;

        [imagesDictionary setObject:imageData forKey:@"IMAGE URL"];

        NSLog(@" Downloading Image...: %@", @"IMAGE URL");

    });

    }

(...)
}

The project in GitHub: https://github.com/GabrielMassana/AsynchronousV2.git

I know that if the project is large and with a lot of cells I can go run out of memory. But I think this solution is a nice approach for a newbie.

What do you think about the project?
If the project is really large, the best option is to save the images in disk? But then the problem is the possibility to go run out of memory in the disk, isn’t it? Maybe, then, we need a mechanism to delete all the images from disk.

  • 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-06-13T02:11:23+00:00Added an answer on June 13, 2026 at 2:11 am

    Use NSCache to hold your downloaded images instead of NSDictionary. This will manage itself in low memory situations and remove items that haven’t been accessed for a while. In that situation, they will be loaded from the URL again if needed.

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

Sidebar

Related Questions

After two days of searching, I'm stuck and could really use some assistance. I
this question might have been answered before, but after two days of searching I
I'm using ubuntu x64, after two days and searching all the net, still i've
After spending roughly two days on this, I'm getting a little rattled. Although by
Edit: Somehow I knew, after two days messing with this, that I'd figure it
I've spent two days on this and have gotten nowhere. I'm trying to use
I have been searching a solution for this since 2 days but couldn't find
After almost two days of searching and R&D finally I've derived some of the
Another hair-puller. AFter two days of fighting with this I cannot figure out what
After wasting two days with this question (and trying to make it work), I've

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.