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

  • Home
  • SEARCH
  • 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 556011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:52:30+00:00 2026-05-13T11:52:30+00:00

I have problem with loading images from the Documents folder of iPhone application into

  • 0

I have problem with loading images from the Documents folder of iPhone application into the tableView.

In a separate request, I check on the server all the images available and download them into the “images” folder under Documents. I am pretty sure that the images are saved correctly.

NSString *filePath = [imagesFolderPath stringByAppendingPathComponent:imageFileName];
    [urlData writeToFile:filePath atomically:NO];
NSLog(@"Saved to file: %@", filePath);

2010-01-22 17:07:27.307 Foo[2102:207] Saved to file: /Users/Hoang/Library/Application Support/iPhone Simulator/User/Applications/6133A161-F9DC-4C92-8AE6-5651022EAA94/Documents/images/86_2.png

[NSBundle mainBundle] is not suitable for loading the images because at runtime, the application tries to connect to the server to download the images, they are not static.

But loading the images from Documents/images folder does not give me the image on the TableView.

static NSString *CellIdentifier = @"CellCategory";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
UIImageView *imageView = cell.imageView;

MenuItem *item = (MenuItem *) [arrayMenuItems objectAtIndex:indexPath.row];
cell.textLabel.text = item.descrizione;


NSString *strImagePath = [[imagesFolderPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%d_%d", item.idItem, item.idNode]] stringByAppendingPathExtension:@"png"];  
NSLog(@"strImagePath: %@", strImagePath);
imageView.image = [[UIImage imageWithContentsOfFile:strImagePath] autorelease];



2010-01-22 17:07:42.842 Foo[2102:207] strImagePath: /Users/Hoang/Library/Application Support/iPhone Simulator/User/Applications/6133A161-F9DC-4C92-8AE6-5651022EAA94/Documents/images/86_2.png

Is there anyone having the same problem?

I have looked around in stackoverflow but have not succeeded.

Thanks in advance.

  • 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-13T11:52:30+00:00Added an answer on May 13, 2026 at 11:52 am

    Edited: ANSWER

    Be sure to check the response on NSData to see if there are images. In my case, all codes are ok, but the response from server give nothing. It is still able to save the image to the file on the documents/images folder, and still not raise any error, until I realized that all the images are not exist on the server. THAT WAS THE ERROR, not relates anything to the Documents folder

    Original answer

    There must be some problems with the initialization code of UIImage.

    I have tried already three initialization functions for image having the path on the Documents directory.

    But it just does not work.

    Here you can see, the code always fall into the (exist) block, the first line is to load the image from the Documents/images directory, it always fails.

    The second line inside the (exist) block, I tried to get the image from the bundle, it works perfect, but it is not what I want.

    Fourth line of code, I get the original link of the images on the server and it gets what I nearly want. (Actually, what I want is to save all the images from the server into the Documents/images directory before hand, and then load them from there)

    NSString *strImagePath = [[imagesFolderPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%d_%d", item.idItem, item.idNode]] stringByAppendingPathExtension:@"png"];  
    NSLog(@"strImagePath: %@", strImagePath);
    
    BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:strImagePath];
    
    if (exists){
        //UIImage *menuImage = [UIImage imageWithContentsOfFile:strImagePath];
        //UIImage *menuImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ALT" ofType:@"png"]];
        //imageView.image = menuImage;
        NSString *strImagePathURL = [NSString stringWithFormat:@"http://foo.com/%d_%d.png", item.idItem, item.idNode];
        NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:strImagePathURL]];
        imageView.image = [[UIImage alloc] initWithData:imageData];
    }
    else {
        imageView.image = [UIImage imageNamed:@"ALT.png"];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer int WINAPI WinMain(....) { MSG msg; WNDCLASS wc={0}; wc.lpszClassName="MyClass"; wc.lpfnWndProc=DefWindowProc;//You… May 16, 2026 at 10:01 am
  • Editorial Team
    Editorial Team added an answer Try using height and width CSS definitions to define the… May 16, 2026 at 10:01 am
  • Editorial Team
    Editorial Team added an answer I have a couple of C# examples on my blog… May 16, 2026 at 10:01 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a JavaScript slideshow that pre-loads images out of a MySQL database and
I have a Windows forms application written in VB.NET where I host multiple WebBrowser
I have a masterpage and inside that masterpage I have to check if a
I have a WPF application which uses a (currently) local database to act as
I have a remote_form which works 100% When a user clicks submit, it goes
So I have a page with an enormous table in a CRUD interface of
I have a script that is being inserted dynamically via another script. The code
Inside a div, there is a picture that should have 10px margin in all
I have a thumbs div (i'm only showing four thumbs for the sake of
Hello I have two dependants select box, the second one is popularited after onchange

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.