Learning Cocoa

by ,

So as part of a project I’m working on, I’m learning some Cocoa.
Originally, because much of the work I’m doing was based on shell scripts, I was hoping I could use the Perl-and-Cocoa stuff, but that fell through when I couldn’t even bring up an Open File dialog.
I’ve heard good things about Cocoa, so I figured this would be a good opportunity to learn it more fully.

I’m finding a lot of attitude in the documentation, mostly along the lines of “Here’s something you could not do in C++ without a lot of pain”.
Unfortunately, whenever I see this, and read the text, I am always thinking “oh yes you could. I could do that in one line!”
Oh well.

Aside from the attitude, the documentation is quite good.
Finding exactly what you want is heard, but that’s always the case.
Right now, for instance, I’m trying to get the IP address of the machine.
Now, yes, there could be multiple ethernet cards, TCP over FireWire, etc, etc.
But all I really want is the TCP/IP address of en0.
The hardware is controlled enough that I can do that.

I downloaded the souce code for ifconfig(!) yesterday, but I think that’s just the wrong way to go.
This app is way too simple to start delving into hudreds of lines of turgid code.
So now I’m going to try using NSTask to just call “ifconfig en0” and save the output somewhere where I can parse it.

Reading the Online Help

At first, I had troubkle reading the online help.
Knowing that Apple Help is a complete dog (it takes about 5 minutes to start up on my dual-1.25 GHz G4), I often find the HTML and drag it into Safari.
I am looking forward to Panther, because Apple Help on Panther uses the same WebKit that Safari uses.
Meanwhile, finding the right HTML page is not painless (I use locate, which means I have to make sure the database is built etc.), and it’s a paint to jump out of what you’re doing, start up Terminal, type in commands to open the right window in the Finder, then drag the icon from the Finder to Safari… yuck.

Well, I had completely forgotten that ProjectBuilder (soon to be renamed Xcode) does not use Apple Help to display its online help!
Egad. (Shut up David).
So now I am using the Help menu in Project Builder a lot.
I am also printing out pieces of the massive 1000+ page PDF that documents all the Foundation classes.
(And when I get to the Application Kit it’s another almost 2000 pages..)

Um, okay, so I think I’ve run oout of things to say, except that hey it’s always fun to learn new stuff.
I just wish there was less “attitude”. šŸ˜›

Just noticed the last menu item under the Help menu in Project builder: Open man page….
Not only does it show the Unix man page for whatever you type, it also puts hyperlinks in all over the place.
This is way useful in the “See also” section.
All the links open new windows, so you can examine multiple man entries simultaneously.



About rae

I'm a long-time Mac and iOS developer. I'm also a big fan of Ruby on Rails and relational databases. I tend to work remotely, in my basement with occasional trips to the office. I'm also a big videophile, both TV and film, and can't wait for a good, inexpensive home 4k solution.

Leave a Reply

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