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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:36:55+00:00 2026-06-09T05:36:55+00:00

NOTE: I am using ARC I have a lazy image loading technique that works

  • 0

NOTE: I am using ARC

I have a lazy image loading technique that works brilliantly when loading images from a web url. However, I am having problems loading images from core data. Here is the method I am using:

I first alloc init my mutable arrays, load my data from core data and then store it in an array. Then I have this code:

NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
                                    initWithTarget:self
                                    selector:@selector(loadImage)
                                    object:nil];
[queue addOperation:operation];

And then…

- (void)loadImage {
    for (int i = 0; i < [myArrayFromCoreData count]; i++) {
        AnObject *myObject = [myArrayFromCoreData objectAtIndex:i];
        UIImage* image;
        if ([myObject.image length] == 0) {
            image = [UIImage imageNamed:@"default.png"];
        }
        else {
            image = [[UIImage alloc] initWithData:myObject.image];
        }
        [self performSelectorOnMainThread:@selector(displayImage:) withObject:[NSArray arrayWithObjects:image,myObject.myObjectId, nil] waitUntilDone:NO];
    }
}

- (void)displayImage:(NSArray*)array {
    [loadedImages setObject:[array objectAtIndex:0] forKey:[array objectAtIndex:1]];
    [self.myTable reloadData];
}

Up to here there is no lag and an NSLog shows that all my images are added to the myObjectLoadedImages array.

The problem I am having is there is a lag when scrolling the table view and it is sometimes causing a crash. Here is the code I am using to display the loaded images:

UIImage* image = [loadedImages objectForKey:myObject.myObjectId];
if (image != NULL) {
    myImageView.image = image;
}
else {
    myImageView.image = [UIImage imageNamed:@"default.png"];
}

This is in the cellForRowAtIndexPath method so it is being called every time the cell is displayed. Is there something I am doing wrong here as my code is adapted from a class which is working fine loading images from a web url.

  • 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-09T05:36:56+00:00Added an answer on June 9, 2026 at 5:36 am

    First thought – you’re not caching your UIImages, so they’re not loaded from memory.

    Have you tried https://github.com/nicklockwood/AsyncImageView/ ?
    In my opinion it’s the best library for loading async images to any view, either from documents and web. It supports cache, progress views and many, many things that simples the code in controllers.

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

Sidebar

Related Questions

I have created an application, using ARC, that parses data from an online XML
Note: Using Monotouch. I have a directory called Images where I have all my
Note: Using Rails 3.1 and current delayed_job gem. I have a User model that
I have a base class line which has a child class arc (note that
I found the following claim in the documentation for Net::OpenSSH : Note that using
Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
[NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My
Note: Using Monotouch and doing all the UI Programatically. Hello everybody, I have a
Note: using MinGW's make (should be GNU make) i have a couple of -include
Note: Using MySQL 4.0, which means no subqueries (at present). I have 2 tables:

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.