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 11:36:36 -0600
On Friday, January 21, 2005, at 11:00AM, Evan Schoenberg <email@hidden> wrote:
>
>On Jan 21, 2005, at 8:32 AM, Ricky Sharp wrote:
>
>> (9) [[NSBundle mainBundle] pathForResource:@"RoundGreenPressed"
>> ofType:nil]
>> * (null)
>>
>> This DOES NOT match expected result. Path should have been returned.
>>
>> (11) [[NSBundle mainBundle] pathForResource:@"RoundRedNormal"
>> ofType:nil inDirectory:@"Images"]
>> * (null)
>>
>> This DOES NOT match expected result. Path should have been returned.
>
>In each of these cases, your file has an extension, though. According
>to the documentation:
>
>- (NSString *)pathForResource:(NSString *)name ofType:(NSString
>*)extension
>Returns the full pathname for the resource identified by name with the
>specified file extension. If the extension argument is nil or an empty
>string (@??), the resource sought is identified by name, with no
>extension.
>
>The methods appear to me to be performing as per documentation.
Thanks for pointing this out. Now that I read it, I can definitely see your point. The doc you quoted above for the pathForResource:ofType: API uses the verbiage "with no extension".
However, the docs for pathForResource:ofType:inDirectory: uses verbiage of "regardless of extension".
I'll go ahead and modify my bug report to show that case (9) is potentially correct (assuming that the docs are correct). But will also add that perhaps some stronger wording is used to make things more obvious.
I'll leave case (11) alone as pathForResource:ofType:inDirectory: contains this in its description:
"The argument extension can be an empty string or nil; in either case the pathname returned is the first one encountered with name, regardless of the extension."
Finally, it could very well be the case where it's the docs that are incorrect for pathForResource:ofType: After all, not sure why that API would not allow for the same rules as pathForResource:ofType:inDirectory:.
What really also gets confusing are the rules that pathForImageResource: uses. The single parameter can either be the image's root name (without extension), or the full name. The see-also link for that API links to pathForResource:ofType: On the surface it would appear that pathForImageResource is implemented via a call to pathForResource:ofType: so not specifying an extension should be legal. OTOH, pathForImageResource also mentions the imageUnfilteredFileTypes: API. It could be the case where patForImageResource contains several blocks of calls to pathForResource:ofType: where the type parameter is always specified (i.e. first try tiff, then png, then pdf, etc.)
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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