Re: Loading images from subfolder of Resources
Re: Loading images from subfolder of Resources
- Subject: Re: Loading images from subfolder of Resources
- From: Ricky Sharp <email@hidden>
- Date: Thu, 20 Jan 2005 21:09:34 -0600
On Jan 20, 2005, at 7:34 PM, Ricky Sharp wrote:
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.
Hmm. If I do specify an extension, then my images are loaded. Perhaps
pathForResource:ofType:inDirectory: is not meant to work where the
ofType param is nil?
I'm going to table this for now as a workaround is to have two blocks
of code. The first will attempt to load a resource of type "pdf" (the
majority of my images) and if the returned path is nil, try again with
a resource of type "tiff".
___________________________________________________________
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