« The Magic and Confusion of an NSCollectionViewGoogle wants free art? »

NuSomewhere

Over the last few days, I’ve been hacking away at a sideproject that I’m calling NuSomewhere. NuSomewhere is a GUI implementation of nu-anywhere which is found in Nu’s examples folder. nu-anywhere is a command line application that injects the Nu runtime and a console into any application. NuSomewhere wraps nu-anywhere and adds a few additional tweaks.

I’ve occasionally picked up some contract work by agreeing to implement Applescript support in applications (and I have some free time, so if you’re a Mac software developer and would like Applescript support, email me and we can work something out). Most of the time, I don’t need access to the source code. I used to use a combination of InputManagers, F-Script Anywhere, and class-dump to figure out how an application worked and then write some categories to implement support. I could then just send that code along with an sdef file. However, as much as I love F-Script, I love Nu more. nu-anywhere let me hack away with Nu, but it didn’t offer all of those great introspection tools that F-Script provided and wasn’t as convenient.

My first goal with NuSomewhere was to make it more convenient. This was as simple as making a GUI for nu-anywhere. I could inject Nu into any running application quickly and easily. The next step was introspection.

Nu already provided some handy extensions to seeing the class and instance methods of an Objective-C object. I added a small bit of code to get at the ivars as well. Then, I just had to write a GUI for viewing these things. A lot of NuSomewhere was just to write the simplest thing that could possibly work. To that end, it just uses standard Cocoa elements and adds a little extra functionality to the console.

F-Script keeps track of all of the variables in the runtime and updates the GUI whenever the user adds a new one. I decided to do something different and added an inspect command to the runtime. Users can write (inspect variablename) and the object will appear in the introspection interface. This lets the user decide what they want to peer into. The other major difference is that the inspector doesn’t do anything to the objects. In F-Script, you can navigate a fairly long way into the application just by clicking around. If NSApp has a delegate, you can click on the delegate listing in the inspector and it’ll load it up so that you can view its information. NuSomewhere takes a different tact and simply throws everything back to the console. This keeps the inspector simple but still provides a decent amount of power.

In the end, NuSomewhere is getting to a place where I can stop relying so heavily on F-Script Anywhere. I can use Nu to my heart’s content and have some of the introspection power that F-Script provided. NuSomewhere was written specifically for my needs, but I’m happy to extend it further. The source code is also available for anyone that wants to fork it and push additional changes.

Leave a Reply