Cocoa Programming Ch. 5 Challenge
Cocoa Programming Ch. 5 Challenge
- Subject: Cocoa Programming Ch. 5 Challenge
- From: Mike Brinkman <email@hidden>
- Date: Wed, 02 Jan 2002 09:05:54 -0500
If you haven't read the Hillegass book, feel free to ignore this. I'm sure
there isn't enough info here if you haven't.
I'm trying to do the first challenge for the RaiseMan program in Chapter 5.
No solution is posted on Techstra, so I figured I'd ask here. I've got an
"almost working" solution, but it isn't exactly right.
Hillegass said to use - (void)tableViewSelectionDidChange:(NSNotification
*)n, but that we could ignore the argument NSNotification *n if I understood
the problem correctly.
Here's my code:
- (void)tableViewSelectionDidChange:(NSNotification *)n
{
int row = [tableView selectedRow];
[deleteButton setEnabled:(([employees count] > 1) && (row != -1))];
}
This code will cause the delete button to be disabled if I highlight a row
and then click on an area of the table without a record (as it should). But
when I create a new record, none of the rows are highlighted, and the delete
button is still enabled. The same thing happens when I delete a record. I
click the delete button, and then the record is deleted, but the delete
button is still enabled despite no row being selected.
Is there something I can do in this method to correct this problem, or would
I have to make changes to updateUI in order to change this behavior?
Thanks again!
Mike Brinkman,
Cocoa programmer in training
--
The premiere source of Mike Brinkman related news on the internet!
http://www.mikebrinkman.com