Chapter 12 from Cocoa Programming for Mac OS X 3rd Ed
Hello,
This is my first post and I am trying to learn Cocoa. I'm working my way through this book and I am stuck on a very specific problem.
I am using 10.6.2 and XCode 3.21 which is a little newer than the book I have.
In chapter 12, you work on an application called RaiseMan which is just a simple application that has a list of people and their raises. It's a Document based application and I have the undo, save and open and basically everything working except one part.
The preferences panel has two options: a checkbox and a colorwell. The checkbox sets defaults that determines if a new document is opened on startup. The colorwell sets the background colour of the tableview control on the main document.
The checkbox is working, the colorwell is not. At least, the color well is setting the color and saving it to the preferences- you can see this when you open the application because the previous color is saved and reloaded. It's supposes to change the table views background while the app is running.
I can't see what I missed and the program is compiling with no errors.
I've been stuck on this for over a week...
I've uploaded my entire project and wondered if someone would look at it??
Attachment: RaiseMan2.zip (2356.0KB)
I'm sorry to hear you are stuck. That's a really good book and everybody agrees it's the best way to learn Cocoa. The code/solutions are available from http://www.bignerdranch.com/solutions/Cocoa-3rd.tgz Build and run the solution. If the solution works, and your code doesn't - maybe you'll find the fix by inspection.
It does say on p197 "Only windows created after the change will be affected" - so are you sure this isn't user error. And use the defaults command (page 208) to be sure the color preference is being stored.
Please let me know if you're 'unstuck', otherwise I'll take a look at your zip on Sunday afternoon (I'm in California).
Yeah- that's the reason I bought the book was because of it's reviews. Thanks for the link- it's just what I needed
I'm not 'unstuck' as it seems. I can't see what's wrong here. I think what I will do is just start over and be more careful. Thank for the link to the book's code though...
Oh, you're still stuck. That's not so good. I'm out of town at the Python Conference in Atlanta this weekend and my iMac is at home. I'll have a look at the zip when I get home on Monday.
Hi Raz
Right. Don't shoot me, I'm only the messenger. It's the piano keys! I don't see this in the book - however if you uncheck the 'Alternating Rows' in InterfaceBuilder on your TableView - it works! Table View Attributes (between Highlight and Col. Sizing) Top/Right of Center in the screenshot:
If this works for you AND you can't see this in Aaron's book either, perhaps you'd like to send him an email. I'm sure he'll be pleased to hear about this (if he hasn't already). I've heard folk say Aaron is very friendly and helpful. Maybe the piano keys arrived with 3.2 or something (I don't remember).
If you're wondering how I found this, then I used the usual divide and conquer strategy. I messed about for an hour or so in the debugger, using defaults read and the sample/solution code. Then I came to the conclusion "there's something in the NIB that's telling him to ignore setBackgroundColor". 2 minutes later it was fixed. The only fun part of debugging anything is the last two minutes when the pain stops.
