1

world! I am trying to use libclang to determine the superclass that an Objective-C method belongs to. I have a cursor representing an instance method (CXCursor_ObjCInstanceMethodDecl). When I get the cursor's parent, I get a cursor of kind CXCursor_ObjCImplementationDecl. I need to be able to get the interface cursor from this last cursor in order to determine the method's superclass. Is there a way to do this?

EJV
  • 1,009
  • 1
  • 10
  • 17

1 Answers1

2

Calling clang_getCanonicalCursor() on the cursor for the @implementation declaration will return the cursor for the @interface declaration. Visiting the children of this cursor will provide access to its superclass reference.

You can also use clang_getOverriddenCursors() on the cursor for the method to determine if it is overriding another from a superclass, protocol, or category.

Matt Stevens
  • 13,093
  • 3
  • 33
  • 27