Tag Archives: instance variables

How to get internals of Objective-C class

DISCLAIMER: This post describes APIs which reference internal methods and could be considered as private API and, therefore, apps could be rejected by Apple’s App Store review team. There is even a special message from Apple to avoid using these techniques in production apps.

There are situations when you want to understand more how your code works. So, you might be interested in getting all the information about particular class, including its instance variables, private methods and so on. There is even one particular reason, you might do that – to avoid accidentally overriding internal methods.

So, let’s create a method which will describe any object. We’re looking for output similar to regular class declaration.

@interface OurClass : ParentClass <Protocols...>
{
    // instance variables
}

// properties, class and instance methods

@end

This declaration will contain definition of all derived methods, variables, including private ones.
Continue reading