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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:36:21+00:00 2026-06-10T15:36:21+00:00

I need to read images from NSDocumentDirectory to multiple uiimageview async so it won’t

  • 0

I need to read images from NSDocumentDirectory to multiple uiimageview async so it won’t block the UI.
I know i can use perform selector in background to load a uiimage, but then how can i associate it with the dynamic uiimageview ?

  • 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-10T15:36:23+00:00Added an answer on June 10, 2026 at 3:36 pm

    One convenient way is to use blocks, something like:

    [self loadFullImageAt:imagePath completion:^(UIIMage * image){
        self.imageView.image = image;
    }];
    

    Where you would load the image as data (since UIImage otherwise loads the image data deferred – when you first access it). It’s also a good idea to decompress the image while still in the background thread, so the main thread doesn’t have to do it when we first use the image.

    - (void)loadFullImageAt:(NSString *)imageFilePath completion:(MBLoaderCompletion)completion {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
            NSData *imageData = [NSData dataWithContentsOfFile:imageFilePath];
            UIImage *image = nil;
            if (imageData) {
                image = [[[UIImage alloc] initWithData:imageData] decodedImage];
            }
            dispatch_async(dispatch_get_main_queue(), ^{
                completion(image);
            });
        });
    }
    

    The callback is defined as:

    typedef void (^MBLoaderCompletion)(UIImage *image);
    

    Here’s an UIImage category that implements the decompression code:

    UIIMage+Decode.h

    #import <UIKit/UIKit.h>
    
    
    @interface UIImage (Decode)
    
    - (UIImage *)decodedImage;
    
    @end
    

    UIIMage+Decode.m

    #import "UIImage+Decode.h"
    
    
    @implementation UIImage (Decode)
    
    - (UIImage *)decodedImage {
        CGImageRef imageRef = self.CGImage;
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGContextRef context = CGBitmapContextCreate(NULL,
                                                     CGImageGetWidth(imageRef),
                                                     CGImageGetHeight(imageRef),
                                                     8,
                                                     // Just always return width * 4 will be enough
                                                     CGImageGetWidth(imageRef) * 4,
                                                     // System only supports RGB, set explicitly
                                                     colorSpace,
                                                     // Makes system don't need to do extra conversion when displayed.
                                                     kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
        CGColorSpaceRelease(colorSpace);
        if (!context) return nil;
    
        CGRect rect = (CGRect){CGPointZero,{CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)}};
        CGContextDrawImage(context, rect, imageRef);
        CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context);
        CGContextRelease(context);
    
        UIImage *decompressedImage = [[UIImage alloc] initWithCGImage:decompressedImageRef scale:self.scale orientation:self.imageOrientation];
        CGImageRelease(decompressedImageRef);
        return decompressedImage;
    }
    
    @end
    

    The sample code provided here assumes that we’re using ARC.

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

Sidebar

Related Questions

i need to get images from a webpage source. i can use cfhttp method
Actually in one of my project i need to read images from remote server
I need to extract images from a FB fan page. I'm able to read
I need a library to read 2D barcode (datamatrix) from images on C# project
I'm doing a theatrical performance, and I need a program that can read images
I try to modify FGallery (https://github.com/gdavis/FGallery-iPhone). I need it to read images from the
I need to make a script to read images from a directory, rename them,
I need load image from assets I can read text file but i can
what is best method to store multiple images (layers) , so user can read(load)
Ok, so I need to build this application where I'll read images from a

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.