• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: imageNamed cannot load an image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: imageNamed cannot load an image


  • Subject: Re: imageNamed cannot load an image
  • From: Artemiy Pavlov <email@hidden>
  • Date: Wed, 21 Mar 2007 23:24:18 +0200


On 21 Mar 2007, at 10:46 PM, Christopher Hickman wrote:

NSImage *BackgroundImage = [NSImage imageNamed:@"SpaceOscillator"];


Try using @"SpaceOscillator.png"

From
http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/Clas
ses/NSImage_Class/Reference/Reference.html:
When looking for files in the application bundle, it is better (but not
required) to include the filename extension in the name parameter. When
naming an image with the setName: method, it is also convention not to
include filename extensions in the names you specify. That way, you can
easily distinguish between images you have named explicitly and those you
want to load from the application's bundle.

Thanks, I just tried this:

NSString* BackgroundImageName = [[NSBundle mainBundle] pathForResource:@"SpaceOscillator.png" ofType:@"PNG"];
NSImage* BackgroundImage = [[NSImage alloc] initWithContentsOfFile:BackgroundImageName];


and this:

NSString* BackgroundImageName = [[NSBundle mainBundle] pathForResource:@"SpaceOscillator" ofType:@"PNG"];
NSImage* BackgroundImage = [[NSImage alloc] initWithContentsOfFile:BackgroundImageName];


And in both cases BackgroundImage is nil...

Are there any extra steps except for dragging an image file into the "Resources" in the XCode project, i.e.:


Attachment: Picture 1.png
Description: application/applefile

PNG image


The image shows up in the IB as "SpaceOscillator" and I can paste it into the view, it will work, but I want to render it as a background.



Thanks very much,

Artemiy
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: imageNamed cannot load an image
      • From: Michael Watson <email@hidden>
References: 
 >imageNamed cannot load an image (From: Artemiy Pavlov <email@hidden>)
 >Re: imageNamed cannot load an image (From: Kevin Hoctor <email@hidden>)
 >RE: imageNamed cannot load an image (From: "Christopher Hickman" <email@hidden>)

  • Prev by Date: Re: Application Caches
  • Next by Date: Re: imageNamed cannot load an image
  • Previous by thread: RE: imageNamed cannot load an image
  • Next by thread: Re: imageNamed cannot load an image
  • Index(es):
    • Date
    • Thread