Doesn’t [self class] do this? The method is within whatever self is, so it seems appropriate that [self class] would provide what you want.
- Jack > On Feb 22, 2015, at 4:41 AM, BareFeetWare <list.develo...@barefeetware.com> > wrote: > > Hi all, > > How can I get the class of a method, at runtime? > > I can get the name of the class methods via: > > Method *methods = > class_copyMethodList(objc_getMetaClass([NSStringFromClass([self class]) > UTF8String]), &methodCount); > for (int i = 0; i < methodCount; i++) { > Method method = methods[i]; > NSString *methodName = NSStringFromSelector(method_getName(method)); > > > And I can get the "returnType" via: > > char *returnType = method_copyReturnType(method); > NSLog(@"The return type is %s", returnType); > > > However, the returnType is just a char that is set to "@" for all classes. I > want to know which class is returned. > > References: > > Apple's documentation on the Objective C runtime library: > https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/index.html > > This article points to some private methods in NSObject that will return the > full syntax of the method header, but is as clueless as I am as to how they > get the class: > http://bou.io/ExtendedTypeInfoInObjC.html > > Any introspective answers out there? > > Thanks, > Tom > > Tom Brodhurst-Hill > BareFeetWare 👣 > > -- > iPhone/iPad/iPod and Mac software development, specialising in databases > develo...@barefeetware.com > -- > Follow us on Twitter: http://twitter.com/barefeetware/ > Like us on Facebook: http://www.facebook.com/BareFeetWare > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/jackbrindle%40me.com > > This email sent to jackbrin...@me.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com