I’m trying to learn Objective-C at the moment, I’ve given up on trying to develop a GUI app for OS X using Java. Learning a new language is a pain. At this point many people would point out that good programming is language agnostic (I’m using that word rather a lot these days in conversations that have nothing to do with religion). ‘A good programmer can use any language to program well’, they would say. At this point I would say I’m a shite programmer. I use Java at work and can accomplish most tasks, none of them are GUI based. In fact what I work on doesnt impact the user interface at all. Not that there is much of one as it’s server side. Anyway, enough digression. I was trying to use the NSOutlineView, for my blogging client, to display titles and contents. Content is a child of a Title which is a child of a Blog, so I had decided to make each blog entry an NSMutableArray. Each array would contain two objects; the title (index 0) and the contents (index 1). This isn’t very clever as it turns out. I looked at examples from Apple and got confused by the sematics of C. I thought the bit of C I had done before would be sufficient along with a copy of Apple’s Objective-C implementation guide. Looks like I need to work on my C as well. I mean, just wtf does return (item == nil) ? 1 : [item numberOfChildren]; mean?

One more digression before the conclusion of this post. I noted in a thread on slashdot that people are pissed off when a search leads them to a blog that doesn’t contain a useful answer to their original query. So with this in mind, I will pass on an example of NSOutlineView that I thought was very good though the author says it’s a bit hasty and not optimal code. I’ve been reading ‘Cocoa Programming’ by Scott Anguish, Erik M. Buck & Donald A. Yacktman and published by SAMS which has a complementary website at http://www.cocoaprogramming.net. In the examples that are downloadable from the site, the Chapter 18 samples contain the Task Outliner sample. Task Outliner demonstrates the use of NSOutlineView quite nicely.

So there.