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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:58:18+00:00 2026-05-27T00:58:18+00:00

I have an app that I am saving images to the NSDocumentDirectory. I can

  • 0

I have an app that I am saving images to the NSDocumentDirectory. I can see that the path is being set correctly but when I try to retrieve them the NSData is null.

Here are some of my snippets..

NSData *imageData  = UIImagePNGRepresentation(image);

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"myApp"];

//Create unique filename
CFUUIDRef newUniqueId = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef newUniqueIdString = CFUUIDCreateString(kCFAllocatorDefault, newUniqueId);
path = [path stringByAppendingPathComponent:(__bridge_transfer NSString *)newUniqueIdString];
path = [path stringByAppendingPathExtension: @"png"];

[imageData writeToFile:path atomically:NO];         

[self showPhoto:path];

Then in my showPhoto method

NSData *pngData = [NSData dataWithContentsOfFile:path];
UIImage *image = [UIImage imageWithData:pngData];

If I debug pngData it is 0 bytes but my path show what I think is the correct path?

Any way of debugging if the photo is actually on the phone? Im not sure if it is getting saved or not.

  • 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-27T00:58:19+00:00Added an answer on May 27, 2026 at 12:58 am

    You can do something like this and check if the file exists first and use imageWithContentsOfFile: to retrieve it.

    NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:localFilePath];
    bool fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagePath];
    
    if(fileExists == YES)
    {
        UIImage *_image = [UIImage imageWithContentsOfFile:localFilePath]
    }
    

    If the image is still empty then there is something wrong with your image.

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

Sidebar

Related Questions

I have a legacy app that seems to be exporting/saving files with CArchive (legacy
have an app that finds your GPS location successfully, but I need to be
I have an app that lets the user interact with several forms. I can
I have an App that downloads and displays images from URL's. This works fine
I have an app on the mac and iPad that stores many images in
I have a iPad app that can take a picture and then put it
I have a Cocoa app that is intended to capture still images from a
I have an application that uses camera to take images. Application works but is
I there a way I can set up my app so that things like
I have an app that shows GIF images. It all works fine if image

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.