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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:03:24+00:00 2026-06-04T17:03:24+00:00

Im saving my images in NSDocumentsDirectory with this: for (int i = 0; i

  • 0

Im saving my images in NSDocumentsDirectory with this:

for (int i = 0; i < info.count; i++) {
    NSLog(@"%@", [info objectAtIndex:i]);
    NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"oneSlotImages%d.png", i]];
    ALAssetRepresentation *rep = [[info objectAtIndex: i] defaultRepresentation];
    UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];
    NSData *imageData = UIImagePNGRepresentation(image);
    [imageData writeToFile:savedImagePath atomically:YES];       
}

Im having difficulty loading them into an array. Ive searched this in the net.
Can this be use for NSDocumentsDirectory?

for(int i = 1; i <= 21; i++)
{
    [images addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Images%d.png", i] ofType:@"jpg"]]];
}
  • 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-04T17:03:25+00:00Added an answer on June 4, 2026 at 5:03 pm

    Is this your actual code?
    There are (at least) two problems if this is the case.
    First, the file names are slightly different in the saving and loading.
    Second, you load pictures from the bundle, and not from the document directory.

    You would want to load them this way?

    Also note, that if you have 20 images that are full res photos, then loading them in an array of UIImages is probably a terrible idea. It will probably crash for lack of memory.

    NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,    NSUserDomainMask ,YES );
    NSString *documentsDir = [paths objectAtIndex:0];
    for(int i = 1; i <= 21; i++)
    {
      NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"oneSlotImages%d.png", i]];
      [images addObject:[UIImage imageWithContentsOfFile:savedImagePath]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code for saving the images. if (RadUploadPageImage.UploadedFiles.Count != 0)
So, I'm currently saving images in my UIImageView via this method: - (void)applicationDidEnterBackground:(UIApplication*)application {
I am saving images to the photo library and would like to retrieve them
Which one is better at runtime: 1)saving images of size 250X120 in sqlite. 2)Saving
So I'm saving small images to core data which take a really short amount
I am saving files (images, Excel doc, Word doc, exe files, bat files and
I am using camera functionality in my application and saving the images in documents
currently i'm trying to use imagick to generate some images without saving them on
I am generating lots of images in java and saving them through the ImageIO.write
I'm creating an app that creates and saves images. Currently I am saving them

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.