Tuesday, February 19, 2002
I’ve been spending some of my screen time for the last few days sitting with the iBook and the (paper) book Learning Cocoa, walking through their tutorial application. Trying to make my brain work like an object-oriented GUI programmer’s.
Woo-haw, is this ever different from what I’m used to! Most of my programming (both work and hobby) has been more down-to-the-bare-metal, even embedded programming. At least, I had some chance of knowing what was going on under and behind my program. Here, there is so much mechanism you have to trust it’s mind-boggling.
I’ve burned through two reams of paper, so far, printing out tutorials and overview documents to read and recycle, in addition to the books I bought. But I haven’t dared to print any of the reference documentation. There are multiple volumes, with four-digit page counts on each volume. I suppose you’re supposed to use them online. That would be easier if I had a real screen instead of the iBook.
I spent the end of yesterday evening (to the point of frustration) and all of this evening trying to solve one little problem. I was in the last few pages of the last big tutorial project in the book. The program had been building and working more or less as described, all along. I had to track down a number of errors, including typing errors of mine, printing errors in the book, minor design quirks in the sample program, and even one case where I’m about 90% convinced that the Cocoa API isn’t doing the right thing. Very educational, and none of the problems had been too hard to solve. But this time, I managed to get stuck. On something stupid, of course.
I thought I’d been messing with trivial settings, like what icon gets displayed for the running program. After going through several of those, following the tutorial instructions, all of a sudden the program didn’t work at all! Instead of bringing up the happy little document window I’d built, it displayed an alert saying “Can’t create new document.” The debugger wouldn’t help me, since the program never got to any of my code. It was going wrong before that, while running the supplied framework code. I started swapping in files from the worked-out sample answers archive, and kept that up until ALL the files had been replaced by the official ones, and it still didn’t work! Gack.
So I went to the Apple site and tried a search for “Can’t create new document” to see if this was a common problem. No matches. Went into the developer area, still no joy. Found a Cocoa developer mailing list, with archives. It even had a search facility. Unfortunately, the search facility doesn’t do phrase matching, and “can’t”, “create”, “new”, and “document” are very common words in the programming forum. Especially “can’t”.
Despite the lack of phrase search, I was lucky enough to stumble onto a message relating the same problem. He was even in the same situation, working through the tutorial in Learning Cocoa. The last message in the thread gave some advice, which I tried. He said be sure to set the Document Class to your specialized type. OK, but I had already done that. But just recently, and the app had been working before that.
To cut to the chase, he was right, but the settings screen for that stuff was confusing me. It turns out the column marked “name” has to be filled in with the magic word “DocumentType” and the specialized type name goes elsewhere, where it does not appear in the table at all. Arrgh. OK, I see now what the headings are supposed to mean, but for a company and a language that prides itself on fine user interfaces, this is pretty horrible.
These settings are stored in one of the files I swapped in. However, the worked-out example was created with the previous version of the developer’s tools, and the file format had to be converted to work with the current tools. It did that automatically (after asking for permission) and that was cool, but it doesn’t seem to have overridden the setting I’d screwed up. Sigh.
I just had to vent.