MoreArty

I've been struggling to do something with NSTask which should be simple. To investigate my problem, I wanted to start with a simple working example of NSTask doing its thing. So I downloaded Apple's example project, called Moriarity.

I've complained about Moriarity before.

  • It uses the ancient pbproj project file format, which no recent version of Xcode can open.
  • The code is messy, with inconsistent indentation.
  • It uses the delegate pattern but calls it a controller, and doesn't name the methods like proper delegate methods.
  • It has a page of boilerplate legalese at the beginning of each file, getting between me and the code.
  • It duplicates class descriptions in the .h and .m files, with the only difference being "This is the header for…" vs. "This is the implementation for…".
  • Text-view ivars are named "…TextField".
  • Ivars are declared as id instead of using explicit class names.
  • The init method for TaskWrapper takes one array argument, the first element of which is the command path, instead of taking separate arguments for the command path and the command arguments.
  • TaskWrapper.h and TaskWrapper.m use "Classic Mac" line endings, which screws up diffs in GitX. Unfortunately I only noticed this after I'd already done some commits. In the future when I grab anyone's code with the intention of putting it in Git, I should make sure all the files have Unix line endings.
  • And of course it misspells "Moriarty".

In short, it drives me nuts. This time, though, I did something about it. I created a new project called "MoreArty". I copied all the Moriarity source files and resources, did some cleanup, and posted the code on GitHub. The next time I want to look at a trivial NSTask example, it won't drive me quite so crazy.

I could easily spend a couple of hours cleaning up the comments, but I left them mostly intact, because I don't have time.

I did notice one odd tidbit I hadn't noticed before. In the nib file, the app delegate is named "WatsonController", which I found interesting for historical reasons.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.