Re: imageNamed cannot load an image
Re: imageNamed cannot load an image
- Subject: Re: imageNamed cannot load an image
- From: James Chen <email@hidden>
- Date: Thu, 22 Mar 2007 17:56:27 +0800
- Thread-topic: imageNamed cannot load an image
Hello,
I think [NSBundle bundleWithIdentifier:] might help.
[[NSBundle bundleWithIdentifier:@"com.your_company.bundleID"]
pathForResource:@"SpaceOscillator" ofType:@"PNG"];
Best Regards,
James Chen
Presentation Product Division
TEL: +886 2 22263630 ext 8538
FAX: +886 2 22267241
Mailto: email@hidden
http://www.avermedia.com
AVerMedia Technologies, Inc.
簡報產品事業單位: 陳銘崧
圓剛科技(股)公司
This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive messages for the
addressee), you cannot use, copy or disclose to any third party or any
information contained in the message. If you have received the message in
error, please advise the sender by reply e-mail and delete the message.
Nothing in this message should be interpreted as a digital or electronic
signature that can be used to authenticate a contract or to other legal
document. Thank you very much.
> From: Artemiy Pavlov <email@hidden>
> Date: Thu, 22 Mar 2007 11:54:18 +0200
> To: James Chen <email@hidden>
> Cc: Michael Watson <email@hidden>, Cocoa <email@hidden>
> Subject: Re: imageNamed cannot load an image
>
> Hello James!
>
> Yes, that's what I thought. However, I used this code even when the
> image is in the main bundle:
>
> NSString* BackgroundImageName = [[NSBundle mainBundle]
> pathForResource:@"SpaceOscillator.png" ofType:@"PNG"];
> NSImage* BackgroundImage = [[NSImage alloc]
> initWithContentsOfFile:BackgroundImageName];
>
> This did not work. But I will see how to access the sub-bundle now.
>
>
> Thanks very much,
>
> Artemiy.
>
>
> On 22 Mar 2007, at 11:46 AM, James Chen wrote:
>
>> Hi,
>> If you're developing a loadable bundle.
>> [NSImage imageNamed:@"whatever"] will looking for the image file in
>> "mainBundle" but not your loadable bundle.
>> You have to use NSBundle's methods to locate your image instead.
>> HTH,
>> James Chen
>
_______________________________________________
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