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

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.

  • Follow-Ups:
    • Re: Getting classes from bundles in an array
      • From: David Newberry <email@hidden>
  • Prev by Date: Re: Setting a class' action
  • Next by Date: Help : File size questions
  • Previous by thread: Re: Getting classes from bundles in an array
  • Next by thread: Re: Getting classes from bundles in an array
  • Index(es):
    • Date
    • Thread