• 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
solved: pathsForResourcesOfType
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

solved: pathsForResourcesOfType


  • Subject: solved: pathsForResourcesOfType
  • From: "Dr. H. Nikolaus Schaller" <email@hidden>
  • Date: Sun, 8 Sep 2002 19:25:53 +0200

Hi,
many thanks to all those who gave me hints.

One of the most important was the link to

http://www.cocoadevcentral.com/tutorials/showpage.php?show=00000059.php

whichs is sample code. Apparently, it uses the NSBundle's class method

+ (NSArray *)pathsForResourcesOfType:(NSString *)extension inDirectory:(NSString *)bundlePath

and passing the

- (NSString *)builtInPlugInsPath

of the main bundle.

My working code now looks like:

{
NSArray *theplugins=[NSBundle pathsForResourcesOfType:@"bundle" inDirectory:[[NSBundle mainBundle] builtInPlugInsPath]];
NSEnumerator* enumerator = [theplugins objectEnumerator];
NSString* pluginPath;
while((pluginPath=[enumerator nextObject]))
{
Class c=[[NSBundle bundleWithPath:pluginPath] principalClass];
if(c != nil && [c instancesRespondToSelector:@selector(write:asType:)])
{
id o=[[[c alloc] init] autorelease];
NSData *d;
d=[o write:self asType:aType];
if(d)
return d; // ok, has been converted
}
}
return nil;
}

Apparently, the documentation for

+ (NSArray *)pathsForResourcesOfType:(NSString *)extension inDirectory:(NSString *)bundlePath

is wrong, as it states that the search path is

<main bundle path>/Resources/bundlePath/name.extension
<main bundle path>/Resources/bundlePath/<language.lproj>/name.extension
<main bundle path>/bundlePath/name.extension
<main bundle path>/bundlePath/<language.lproj>/name.extension

But if that were true, it should NOT work passing builtInPlugInsPath.

I assume, the search path is
bundlePath/name.extension
bundlePath/<language.lproj>/name.extension

with bundlePath being absolute.

Apple, please correct or make the description and the differences between
+ (NSArray *)pathsForResourcesOfType:(NSString *)extension inDirectory:(NSString *)bundlePath
- (NSArray *)pathsForResourcesOfType:(NSString *)extension inDirectory:(NSString *)bundlePath

more clear.

Nikolaus Schaller
+-------------------+
! email@hidden !
+-------------------+
_______________________________________________
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.

  • Prev by Date: gdb mycommand -withargsformycommand
  • Next by Date: Re: gdb mycommand -withargsformycommand
  • Previous by thread: Re: Drawer size reverts to window size automatically. Why?
  • Next by thread: Controlling number of bounces of app icon at launch
  • Index(es):
    • Date
    • Thread