Loading images from subfolder of Resources
Loading images from subfolder of Resources
- Subject: Loading images from subfolder of Resources
- From: Ricky Sharp <email@hidden>
- Date: Thu, 20 Jan 2005 19:34:50 -0600
Up until today, all my images (mostly PDF, but some TIFF) were placed
directly into the Resources folder of my app bundle. I used NSBundle's
pathForResource:ofType: to obtain the path of an image which I then fed
into NSImage's initWithContentsOfFile:.
I'm now creating an "image factory" object that will be able to load
images from different subfolders within Resources. I started out by
setting up my project to place an Images folder within Resources and
then have all my images reside in Images. That was the easy part.
I then looked at using NSBundle's pathForResource:ofType:inDirectory:
NSString* theImagePath = [NSBundle pathForResource:aName ofType:nil
inDirectory:[[aBundle resourcePath]
stringByAppendingPathComponent:@"Images"]];
where aName is the root name of some image and aBundle is usually the
result of [NSBundle mainBundle].
However, theImagePath is always nil.
I must be misusing this API. I also could not find any code examples.
The docs just say that the directory must be a valid path or nil.
FWIW, I also tried using an absolute path for the inDirectory
parameter, but still got a nil result.
Am I able to use this API to effectively load resources from a
subfolder of Resources? Note that in my case, I don't want to specify
an extension because my images will ultimately be in many formats.
This is why I'm not building up paths directly to the images; I don't
know their extension.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden