Interface Inspector

Written by Stephan Michels on 21. September 2013. Posted in Uncategorized

I finally finished first my own software product called Interface Inspector. I wrote the Interface Inspector to debug my own applications during the development to see which are the visible views and their properties. I often have the problem that I don’t know why specific views are not visible or display a wrong content. With this tool I can now inspect the running application and see all necessary information. Moreover I can introspect other applications to see how they manage to build a specific design. A great way to learn from others.

The Interface Inspector is currently published as a public beta version and I hope this tool will be helpful for others too.

Screenshot of the Interface Inspector


Debug all called Objective-C methods

Written by Stephan Michels on 31. Januar 2013. Posted in Uncategorized

Once in a while I need to know which methods are called in my code. The simplest solution is to add a breakpoint on the function called objc_msgSend. This function is responsible for the call of every method in Objective-C

id objc_msgSend(id theReceiver, SEL theSelector, ...)

In Xcode you can add actions to breakpoints. In my case add a debugger command to evaluate the receiver and the selector. So I added following command:

expr -- (void)printf("[%s %s]\n",(char *) object_getClassName(*(long*)($rdi)), (char *)($rsi))

You might ask where I get the register names from. I found a good article on expaining the various registers of the different platforms: „Inspecting Obj-C parameters in gdb„.

Important is that you enable „Automatically continue after evaluating“.

Breakpoint on objc_msgSend

Breakpoint on objc_msgSend

Now you get a Output like this

[__NSCFConstantString copy]
[__NSCFConstantString copyWithZone:]
[NSObject valueWithRect:]
[NSObject valueWithBytes:objCType:]
[NSConcreteValue init]
[NSObject resolveInstanceMethod:]
[NSConcreteValue description]
[NSConcreteValue getValue:]
[NSObject stringWithFormat:]

Implementation of an inspector tab bar

Written by Stephan Michels on 29. Mai 2012. Posted in Uncategorized

For my own project I tried to create a similar tab bar like I have seen in the Xcode
inspector. Some of you might be interested in the source code, so I made it free and without any

It took some time to find out how to create NSButtons witch look and work identical to
the tab bar buttons like in Xcode. First I created an custom NSButtonCell subclass to
draw the shadows left and right of the button to mimic the shadow of the selected

    - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView {
        // Draw background only if the button is selected
        if (self.state == NSOnState) {
            [... draw shadow ...]

To get the etched look of icons you have to use template images and set the bezel style
of the button cell.

    self.bezelStyle = NSTexturedRoundedBezelStyle;

For the functional part, I have struggled a long time with the button action which has been
sent on the mouse up event. I wanted to switch the views on the mouse down event. Following
statement allows the button to send the action of the mouse down event.

    [button sendActionOn:NSLeftMouseDownMask];

The next problem was that button changed it’s state even if the button has already been
selected. To prevent this behavior I overrode the following method in the button cell.

    // prevent automatic state changes
    - (NSInteger)nextState {
        return self.state;

Everything else was straight forward. I hope you find the tips and tricks useful. You
can find the source code on GitHub.