• 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
Getting classes from bundles in an array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting classes from bundles in an array


  • Subject: Getting classes from bundles in an array
  • From: David Newberry <email@hidden>
  • Date: Thu, 15 Aug 2002 01:36:35 -0700

Hi All,

This is kind of an odd question... I'm afraid I'm doing something weird but I can't figure it out. What I'm doing is adding all the bundles in a directory to an array, then later iterating through the array and trying to get the class in each bundle with a particular name. The odd behavior is that I only seem to be able to get the class from the last item added to the array.

NSArray *getPluginBundles( void )
{
NSEnumerator *e;
NSString *dir;
BOOL isDir;
NSString *scanDir;
NSMutableArray *ret;

ret = [[NSMutableArray alloc] initWithCapacity:5];

scanDir = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"../plugins"];

if (![[NSFileManager defaultManager] fileExistsAtPath:scanDir isDirectory:&isDir]) return nil;
if (!isDir) return nil;

e = [[[NSFileManager defaultManager] directoryContentsAtPath:scanDir]
objectEnumerator];
while (dir = [e nextObject]) {
if ([[dir pathExtension] isEqualToString:@"bundle"])
[ret addObject:[[NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/%@", scanDir, dir]] retain]];
}

return ret;
}

The only thing I'm doing with the array is this within a loop:

plugin = [plugins objectAtIndex:index];
pluginClass = [plugin classNamed:@"BEPlugin"];

I know that the correct bundles are being added to the array. If I log a description of the bundle before trying to access the class, I can see that it is indeed the correct file, and it shows the bundle as being loaded. The pluginClass variable stays fixed with the value 0x0 though... (for the first but not the second bundle...) I'm at a loss.

Thanks in advance for any help.

Peace,
-David Newberry
_______________________________________________
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: Getting classes from bundles in an array
      • From: Ondra Cada <email@hidden>
  • Prev by Date: cocoa and argv
  • Next by Date: NSCountWindows
  • Previous by thread: Re: cocoa and argv
  • Next by thread: Re: Getting classes from bundles in an array
  • Index(es):
    • Date
    • Thread