Re: Getting classes from bundles in an array
Re: Getting classes from bundles in an array
- Subject: Re: Getting classes from bundles in an array
- From: Brian Webster <email@hidden>
- Date: Thu, 15 Aug 2002 09:14:28 -0500
On Thursday, August 15, 2002, at 07:30 AM, cocoa-dev-
email@hidden wrote:
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.
<snip>
The only thing I'm doing with the array is this within a loop:
plugin = [plugins objectAtIndex:index];
pluginClass = [plugin classNamed:@"BEPlugin"];
The problem is that you can't have more than one class loaded in
an application with the same name. Usually the way to handle
loading classes from bundles like this is to make the class you
want to load the principal class for the bundle. When you build
the bundle, set the NSPrincipalClass key in your Info.plist to
the class you want. Then, when you load the bundle, you can
just call principalClass to get the class object. That way, you
don't even need to know the name of the class you're loading,
although you still need to make sure that the names are unique.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.