Tue 30 Sep 2008
It’s been a while since I’ve posting anything about coding/development… not because I’ve gotten out of it. Mostly because I’m swimming in it. Drowning some days, it seems like. And while I can’t talk specifically about what I’ve been working on over at Startly just yet (invoke your Carnac skills and I’m sure you can guess) there are some choice things I’ve created that might be interesting to you… my five loyal readers.
When you write code, you spend a lot of time wondering (usually out loud and with anger in your words) what exactly is getting passed around in your program… especially when things aren’t working right. And while debugging can get you those answers, it’s sometimes a pain to have to break in a method every single time just to see the value or address of an argument.
Yes, programmers are a lazy lot. Any time we have to do something more than three times, we get cranky and spend way-too-many hours coming up with a solution to never have to do that “thing” again. For me, writing NSLog()s at the top of methods is one of those things.
Cocoa methods look like this:
where aView, place, and otherView are the arguments passed to the method addSubview:positioned:relativeTo: (For my non-programmer readers, you should have stopped reading a long time ago). So if you wanted to see what was passed to this method (and subsequently call super’s implementation so everything continues to work), you’d have to type all of this:
- {
- NSLog( @"addSubview:%@ positioned:%d relativeTo:%@ ", aView, place, otherView );
- [super addSubview:aView positioned:place relativeTo:otherView];
- }
I know!! Look at all that typing! 262 keystrokes just to see if the subview you’re getting is the right one! (yes, I wrote a perl script to count the number of characters in that snippit…)
So this morning I wrote some perl code that, with a simple highlight of the method and a keystroke (or menu selection) will do all of that for you (sans telling you how many keystrokes you saved)
(No, I’ve not paid for Screen Mimic. $65 for a one-time ten second movie clip is a bit much so I’m not upset they put a watermark on the video. It’s pretty cool software, though. Check it out if you need to make videos like this.) My apologies for the way-too-large video… you get the idea, though.
Anywho, that’s what easyNSLog.pl does. It takes the tedium out of typing NSLog/[super] over and over again. It’s free (MIT License because everything needs a friggin’ license these days) and available here. I’d love to hear any feedback or requests for improvements. My email is in the script’s comments or feel free to leave a comment here.

John, the owner, greeted us warmly, offered us water, bathroom, etc. Talking with John, we found out there were seven people registered to run this 10K. “Well, we’ll have eight now with me here” I said. In reality, we had three. Myself and two women who work for Best Buy corporate. When it was clear this was going to be it, John gave us the “prizes” that were supposed to be drawn for after the race; a new Nike+ Sportband for each of us. Pretty cool (although I have little use for it with my Nano).