• 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: Loading a class with a specific superclass from a bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading a class with a specific superclass from a bundle


  • Subject: Re: Loading a class with a specific superclass from a bundle
  • From: Chris Hanson <email@hidden>
  • Date: Tue, 05 Aug 2008 12:59:19 -0700

On Aug 5, 2008, at 11:19 AM, Elan Feingold wrote:

I can load the principal class of a bundle with:

NSBundle* bundleToLoad = [NSBundle bundleWithPath:@"..."];
Class exampleClass = [bundleToLoad principalClass]);

Actually, this loads the bundle and then gets its principal class. Loading a bundle will load all of the classes in it, regardless of whether you're just asking for the principal class


However, I have a situation where I have a bundle that has a class *without* a principal class, but it has a class that is a subclass of a specific other class. Is there any way to iterate through classes offered by a bundle and pick out the ones that derive from a specific superclass?

As others have explained, a bundle always has a principal class; if one isn't specified, one of the classes defined within the bundle will be returned.


What you probably want to do is load the bundle and then look through the Objective-C runtime for classes whose superclass is one of those you care about. You can use objc_getClassList to iterate over the classes known to the runtime, and objc_getSuperclass to locate the superclass of a class. (There's no objc_getSubclassList.)

  -- Chris

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Loading a class with a specific superclass from a bundle
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >Loading a class with a specific superclass from a bundle (From: Elan Feingold <email@hidden>)

  • Prev by Date: Re: ERROR in Xcode 3 Unleashed
  • Next by Date: Re: Using performSelector: on super
  • Previous by thread: Re: Loading a class with a specific superclass from a bundle
  • Next by thread: Re: Loading a class with a specific superclass from a bundle
  • Index(es):
    • Date
    • Thread