• 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: Class method list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Class method list


  • Subject: Re: Class method list
  • From: Sherm Pendley <email@hidden>
  • Date: Thu, 19 Dec 2002 08:19:23 -0500

On Thursday, December 19, 2002, at 06:54 AM, TACKEL wrote:

Could you give me
any idea to get all the
methods available for
one class?

It depends on what you want to do with the list - There's more than one way to do it.

The simplest way, of course, is to just look them up in the docs. But I'm guessing that you knew that. :-)

The medium way is to use the "class-dump" tool, which you can install easily using Fink. If getting the list of methods at compile-time is what you need, "class-dump" is the way to go.

The hard way is to use the Objective-C runtime functions. If you need to list the methods at runtime, this is what you'll want to do. Apple's "The Objective-C Programming Language," available in PDF form at apple.com, documents all of the runtime functions, but here's a quick-n-dirty example:

#import <Foundation/Foundation.h>
#include <objc/objc-runtime.h>

int main (int argc, const char * argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Class ws = objc_getClass("NSObject");
void *iterator = 0;
struct objc_method_list *mlist;
int i;

mlist = class_nextMethodList(ws, &iterator);
while (mlist != NULL) {
for(i=0; i<mlist->method_count; i++) {
SEL aSel = mlist->method_list[i].method_name;
NSLog(@"Found selector %@", NSStringFromSelector(aSel));
}
mlist = class_nextMethodList(ws, &iterator);
}

[pool release];
return 0;
}

sherm--

UNIX: Where /sbin/init is Job 1.
_______________________________________________
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.

References: 
 >Class method list (From: TACKEL <email@hidden>)

  • Prev by Date: Re: NSUserDefauts - Am I Missing the Obvious?
  • Next by Date: Re: "First Run" installation of Application support stuff?
  • Previous by thread: Re: Class method list
  • Next by thread: Re: Class method list
  • Index(es):
    • Date
    • Thread