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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:07:31+00:00 2026-05-26T01:07:31+00:00

Currently i’m using these codes to save my images into NSDocumentDirectory. I use this

  • 0

Currently i’m using these codes to save my images into NSDocumentDirectory. I use this counter as the naming convention for them.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo 
{
  [self.popoverController dismissPopoverAnimated:YES];
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDir = [paths objectAtIndex:0];
  NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%d.png", counter]];
  UIImage *image = imageView.image;
  NSData *imageData = UIImagePNGRepresentation(image);
  [imageData writeToFile:savedImagePath atomically:NO];
}

I use this method because it’s easier for me to retrieve all of them by using a loop. I want to retrieve all the images from the NSDocumentDirectory so that i can display them in another view. The following codes show how i retrieve them.

-(NSMutableArray *)GetImage:(NSMutableArray *)arrayImgNames
{
  NSMutableArray *tempArray;
  for(int i=0;i<[arrayImgNames count]; i++)
  {
    NSArray *paths1 = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths1 objectAtIndex:0];
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent: [arrayImgNames objectAtIndex:i]];
    [tempArray addObject:[[UIImage alloc] initWithContentsOfFile:filePath]];
    return tempArray;
  }
}

However, i do not wish to use the counter as a naming convention for my images. I want to use proper names for them but if i do so, i will have to change my method of retrieving all the images.

Is there any other way that i can retrieve all images other than this method i mentioned?

  • 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-26T01:07:31+00:00Added an answer on May 26, 2026 at 1:07 am

    You can retrieve files using next approach:

    NSURL *url = [[AppDelegate sharedAppDelegate] applicationDocumentsDirectory];
    NSError *error = nil;
    NSArray *properties = [NSArray arrayWithObjects: NSURLLocalizedNameKey, NSURLLocalizedTypeDescriptionKey, nil];
    
    NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:url
                      includingPropertiesForKeys:properties options:(NSDirectoryEnumerationSkipsPackageDescendants)
                      error:&error];
    

    In files paths to all files of documents directory will be stored. Next code will help you to get there names:

    NSURL *url = [files objectAtIndex:index];
    NSString *localizedName = [url lastPathComponent];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently I am using a pretty basic function to pre-load images: function preload(arrayOfImages) {
Currently I know of only two ways to cache data (I use PHP but
Currently, I am developing a product that does fairly intensive calculations using MS SQL
Currently I using the following code to get my JSON output from MySQL. <?php
Currently I use [Authorize(Roles = .....)] to secure my controller actions on my ASP.NET
Currently I am debugging the signing of an Android app. And this would be
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
Currently in my webpage i load images to the ListView object as follows... <ContentTemplate>

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.