• 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
bug in NSBundle pathForResource:ofType:inDirectory: ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug in NSBundle pathForResource:ofType:inDirectory: ?


  • Subject: bug in NSBundle pathForResource:ofType:inDirectory: ?
  • From: "Dr. H. Nikolaus Schaller" <email@hidden>
  • Date: Sat, 1 May 2004 15:35:01 +0200

Hi,
I am trying to make the following code work with Xcode 1.1 and OS X 10.3.3:

NSBundle *b=[NSBundle bundleForClass:[self class]];
NSString *name=[b objectForInfoDictionaryKey:@"ImageFile"];
NSString *path=[b pathForResource:name ofType:nil inDirectory:nil]; // find resource of any extension
NSLog(@"%@ icon %@ at %@", b, name, path);
return [[[NSImage alloc] initWithContentsOfFile:path] autorelease];

It does not find anything (returns nil). When changeing the ofType:nil to ofType:@"gif", it finds the file - if it really has the extension .gif.

This is not as described in the online documentation [[extensions from me]]:

- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)bundlePath

Returns the full pathname for the resource identified by name, with the specified filename extension, and residing in the [[ bundle sub-]] directory bundlePath; returns nil if no matching resource file exists in the bundle. The argument bundlePath must be a valid bundle directory or nil [[which means the bundle resources directory itself]]. 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.

The method seems not to behave like described on the last sentence.

Any ideas, hints?

Thanks,
Nikolaus
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: bug in NSBundle pathForResource:ofType:inDirectory: ?
      • From: Douglas Davidson <email@hidden>
    • Re: bug in NSBundle pathForResource:ofType:inDirectory: ?
      • From: Allan Odgaard <email@hidden>
  • Prev by Date: isDirectory and real folders
  • Next by Date: Re: isDirectory and real folders
  • Previous by thread: Re: isDirectory and real folders
  • Next by thread: Re: bug in NSBundle pathForResource:ofType:inDirectory: ?
  • Index(es):
    • Date
    • Thread