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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:02:59+00:00 2026-05-13T01:02:59+00:00

I can’t seem to load an image, but I’m sure it is at the

  • 0

I can’t seem to load an image, but I’m sure it is at the path I specify.

Here is the code that tries to load the image:

- (UIImage*) CPPlistImageToUIImage: (NSString *) CPPlistImage {
    /*TODO: Is this a memory leak? Find out*/
    UIImage * ret = [UIImage imageNamed: CPPlistImage];
    if(ret == nil){
        RDLogString(@"Warning: Failed to load image: \"%@\"", CPPlistImage);
    }

    return ret;
}

And here is a function that lists all the files in the directory where this function looks:

- (void) lsOwnDirectory {
    NSError * error = [[NSError alloc] init];
    NSArray * files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: pathToOwnDirectory error: &error];

    for(NSString * file in files){
        RDLogString(@"%@", file);
    }
}

And here is a sample of the output of both functions in the same run:

// CPPlist...Image telling he can't find/load the image
2009-11-29 02:12:51.510 CPPlayer[6452:207] CPConversation.m:113 Warning: Failed to load image: "/Users/nick/Library/Application Support/iPhone Simulator/User/Applications/D3403591-3A56-4F05-B4C1-C21DAAF918A2/CPPlayer.app/CP.Resources/CP.Conversations/Supermarkt/OIGNONS.png"
...
// lsOwnDirectory is called AFTER CPPList...Image
2009-11-29 02:12:51.557 CPPlayer[6452:207] RootViewController.m:81 Contents of /Users/nick/Library/Application Support/iPhone Simulator/User/Applications/D3403591-3A56-4F05-B4C1-C21DAAF918A2/CPPlayer.app/CP.Resources/CP.Conversations/Supermarkt
2009-11-29 02:12:51.566 CPPlayer[6452:207] CPConversation.m:133 audio
2009-11-29 02:12:51.567 CPPlayer[6452:207] CPConversation.m:133 CPConversation.plist
2009-11-29 02:12:51.568 CPPlayer[6452:207] CPConversation.m:133 CPData.sqlite
2009-11-29 02:12:51.569 CPPlayer[6452:207] CPConversation.m:133 images
2009-11-29 02:12:51.570 CPPlayer[6452:207] CPConversation.m:133 OIGNONS.png

I have no clue why it can’t find the file. One function sees it, the other does not, they seem to look in the same directory…

Any help, greatly appreciated,

Thanks in advance,
Nick

Edit:
I forgot to add that the code is executed and compiled by xcode for the iPhone OS 3.0. You probably got that from the tags but still.

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

    -[UIImage imageNamed:] does not accept a full path to the image file – it only accepts a filename and then looks for an image with that filename in the application’s main bundle. That’s why it returns nil. -[UIImage imageWithContentsOfFile:], on the other hand, expects a full or partial path to the file. The major difference between the two constructors is that imageNamed: caches the image internally (in a private cache specific to UIImage), whereas imageWithContentsOfFile: will not cache the image.

    Sidenote: No, that’s not a memory leak. You’re using a convenience constructor which according to the memory management rules for Cocoa should return an autoreleased object that you do not take ownership of unless you explicitly retain it elsewhere.

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

Sidebar

Related Questions

Can we change the default action of the edit selected row button? Here is
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
Can I be sure about the order in a Python dictionary? The function op.GetTangent(id)
Can I call select before recv_from on a socket that is blocking?
Can I have a project that has some parts written in c and other
Can some one confirm me that only one UIWindow instance is possible in any
Can we change the color of the divider? Apple documentations says, that we can
Can't seem to figure out what's wrong with the simple getJSON call below. It's
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Can anybody shed some light on getDay() in Javascript please. Here datepicker is textbox

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.