• 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: Loading images from subfolder of Resources
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Loading images from subfolder of Resources
      • From: Evan Schoenberg <email@hidden>
References: 
 >Loading images from subfolder of Resources (From: Ricky Sharp <email@hidden>)
 >Re: Loading images from subfolder of Resources (From: "M. Uli Kusterer" <email@hidden>)
 >Re: Loading images from subfolder of Resources (From: Ricky Sharp <email@hidden>)
 >Re: Loading images from subfolder of Resources (From: "M. Uli Kusterer" <email@hidden>)
 >Re: Loading images from subfolder of Resources (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Pictures as characters
  • Next by Date: Re: Pictures as characters
  • Previous by thread: Re: Loading images from subfolder of Resources
  • Next by thread: Re: Loading images from subfolder of Resources
  • Index(es):
    • Date
    • Thread