• 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 a list of all classes, etc...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting a list of all classes, etc...


  • Subject: Re: Getting a list of all classes, etc...
  • From: "Sherm Pendley" <email@hidden>
  • Date: Wed, 26 Mar 2008 22:19:23 -0400

On Wed, Mar 26, 2008 at 10:01 PM, Graham Cox <email@hidden> wrote:

> Is there a way to obtain from the runtime a list of all classes that
> are subclasses of a given class, or failing that, a list of all
> classes that I can iterate and test with isKindOfClass:?


Here's the function I use in CamelBones to iterate through all registered
classes. It hasn't been updated to Leopard's new ObjC 2.0 runtime yet, but
neither have most Mac users. :-)

// Create Perl wrappers for all registered ObjC classes
void REAL_CBWrapRegisteredClasses(void) {
    int numClasses;
    Class *classes;
    int i;

    classes = NULL;
    numClasses = objc_getClassList(NULL, 0);
    if (numClasses > 0) {
        classes = malloc(sizeof(Class) * numClasses);
        objc_getClassList(classes, numClasses);
        for(i=0; i < numClasses; i++) {
            REAL_CBWrapObjectiveCClass(classes[i]);
        }
        free(classes);
    }
}

sherm--
_______________________________________________

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: Getting a list of all classes, etc...
      • From: Graham Cox <email@hidden>
References: 
 >Getting a list of all classes, etc... (From: Graham Cox <email@hidden>)

  • Prev by Date: CoreAnimation weird problems with NSView animator
  • Next by Date: Core Data/IB questions
  • Previous by thread: Getting a list of all classes, etc...
  • Next by thread: Re: Getting a list of all classes, etc...
  • Index(es):
    • Date
    • Thread