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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:09:39+00:00 2026-05-26T00:09:39+00:00

I’m developing this application on an iPad. It has a function that allows user

  • 0

I’m developing this application on an iPad.
It has a function that allows user to store images from the iPad’s photo gallery into the application via NSDocumentDirectory.

There’s a browse button, confirm button and one imageview in the first screen.
The browse button will display the photos from the iPad’s photo gallery and allows the user to select a photo.
The confirm button will store the selected photo into NSDocumentDirectory.

Browse button:

- (IBAction) browsePhoto:(id)sender
{
  UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
  imagePickerController.delegate = self;
  imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
  [popover setPopoverContentSize:CGSizeMake(320,320)];
  [popover presentPopoverFromRect:CGRectMake(200,200,-100,-100) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
  self.popoverController = popover;
  [imagePickerController  release];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editingInfo 
{
  [self.popoverController dismissPopoverAnimated:YES];
  imageView.image = selectedImage;
}

Confirm button:

- (IBAction) confirmPhoto:(id)sender
{
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDir = [paths objectAtIndex:0];
  NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:@"SavedImage.png"];
  UIImage *image = imageView.image;
  NSData *imageData = UIImagePNGRepresentation(image);
  [imageData writeToFile:savedImagePath atomically:NO];
}

I used these codes to try out on ONE image, so it will be working perfectly fine.
But after some time, i found out that i have to allow the user to store more than one photos. My codes are unable to do that because i somehow ‘hardcode’ the file name which is SavedImage.png and the new image will simply replace the old image.

I have thought of a method to solve this, which is by using a counter to name the images when i store them into my application.
Something like that:

NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%d.png", counter]];

But this will not be a good naming convention for my images. I want to save them with proper names. What i have thought of, is that when the user tap on the confirm button, the application will display a message box that prompts and allows user to key in the name of the image that’s being selected. The image will then be saved as the name that the user have entered.

  • 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-26T00:09:39+00:00Added an answer on May 26, 2026 at 12:09 am

    Create a little ViewController with an UITextField and 2 buttons for OK and ABORT and show it with a UIPopOverController. You should be aware, that you must check for legal filenames, check for files already existing (and allow overwriting).

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

Sidebar

Related Questions

No related questions found

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.