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: Fri, 21 Jan 2005 08:32:30 -0600
I've just filed <rdar://3966142>
Here are the results of a test app I came up with. It shows that the following APIs do not work with 'type' parameter set to nil or the empty string (even though the docs in all cases say you can use such values):
APIs that fail...
- pathForResource:ofType:
- pathForResource:ofType:inDirectory:
+ pathForResource:ofType:inDirectory:
Image locations in the app bundle...
+ Contents
+ Resources
+ English.lproj
* RoundGreenNormal.pdf
* RoundGreenPressed.tiff
+ Images
* RoundRedNormal.pdf
* RoundRedPressed.tiff
* RoundAquaNormal.pdf
* RoundAquaPressed.tiff
Results...
[Session started at 2005-01-21 07:40:52 -0600.]
(1) [NSBundle pathsForResourcesOfType:@"pdf" inDirectory:@"Images"]
<nil array>
This matches expected result of failure. After all, we are not providing the actual bundle where the "Images" folder resides in.
(2) [NSBundle pathsForResourcesOfType:@"pdf" inDirectory:theAbsoluteImageFolderPath
* /Users/.../Contents/Resources/Images/RoundRedNormal.pdf
This matches expected result of success.
(3) [[NSBundle mainBundle] pathsForResourcesOfType:@"pdf" inDirectory:@"Images"]
* /Users/.../Contents/Resources/Images/RoundRedNormal.pdf
This matches expected result of success.
(4) [NSBundle pathsForResourcesOfType:nil inDirectory:@"Images"]
<nil array>
This matches expected result of failure. After all, we are not providing the actual bundle where the "Images" folder resides in.
(5) [NSBundle pathsForResourcesOfType:nil inDirectory:theAbsoluteImageFolderPath
* /Users/.../Contents/Resources/Images/RoundRedNormal.pdf
* /Users/.../Contents/Resources/Images/RoundRedPressed.tiff
This matches expected result of success.
(6) [[NSBundle mainBundle] pathsForResourcesOfType:nil inDirectory:@"Images"]
* /Users/.../Contents/Resources/Images/RoundRedNormal.pdf
* /Users/.../Contents/Resources/Images/RoundRedPressed.tiff
This matches expected result of success.
(7) [[NSBundle mainBundle] pathForResource:@"RoundAquaNormal" ofType:nil]
* (null)
This DOES NOT match expected result. Path should have been returned.
(8) [[NSBundle mainBundle] pathForResource:@"RoundAquaNormal" ofType:@"pdf"]
* /Users/.../Contents/Resources/RoundAquaNormal.pdf
This matches expected result of success.
(9) [[NSBundle mainBundle] pathForResource:@"RoundGreenPressed" ofType:nil]
* (null)
This DOES NOT match expected result. Path should have been returned.
(10) [[NSBundle mainBundle] pathForResource:@"RoundGreenPressed" ofType:@"tiff"]
* /Users/.../Contents/Resources/English.lproj/RoundGreenPressed.tiff
This matches expected result of success.
(11) [[NSBundle mainBundle] pathForResource:@"RoundRedNormal" ofType:nil inDirectory:@"Images"]
* (null)
This DOES NOT match expected result. Path should have been returned.
(12) [[NSBundle mainBundle] pathForResource:@"RoundRedNormal" ofType:@"pdf" inDirectory:@"Images"]
* /Users/.../Contents/Resources/Images/RoundRedNormal.pdf
This matches expected result of success.
(13) [[NSBundle mainBundle] pathForResource:@"RoundRedPressed" ofType:nil inDirectory:theAbsoluteImageFolderPath]
* (null)
Not sure why this would fail. Apparently absolute paths are not allowed.
(14) [[NSBundle mainBundle] pathForResource:@"RoundRedPressed" ofType:@"tiff" inDirectory:theAbsoluteImageFolderPath]
* (null)
Not sure why this would fail. Apparently absolute paths are not allowed.
(15) [NSBundle pathForResource:@"RoundRedPressed" ofType:nil inDirectory:theAbsoluteImageFolderPath]
* (null)
This DOES NOT match expected result. Path should have been returned.
(16) [NSBundle pathForResource:@"RoundRedPressed" ofType:@"tiff" inDirectory:theAbsoluteImageFolderPath]
* /Users/.../Contents/Resources/Images/RoundRedPressed.tiff
This matches expected result of success.
_______________________________________________
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