Re: Cocoa Programming Ch. 5 Challenge
Re: Cocoa Programming Ch. 5 Challenge
- Subject: Re: Cocoa Programming Ch. 5 Challenge
- From: Jens Bauer <email@hidden>
- Date: Thu, 3 Jan 2002 16:48:35 +0100
Hi Mike,
On Wed, 2 Jan, 2002, Mike Brinkman <email@hidden> wrote:
>
Here's my code:
>
>
- (void)tableViewSelectionDidChange:(NSNotification *)n
>
{
>
int row = [tableView selectedRow];
>
[deleteButton setEnabled:(([employees count] > 1) && (row != -1))];
>
}
Try this instead:
[deleteButton setEnabled:(([employees count] > 0) && (row != -1))];
If we have more than 0, we have at least 1. Earlier you were demanding at
least 2 to delete one.
-As I've not read the book yet, and I don't have the entire code, I
cannot tell you if this is exactly what is wrong. You may want to change
the line into...
[deleteButon setEnabled:row != -1];
..to test if it works at all.
I guess that the row variable is -1 if nothing is selected, otherwise
it's the item number
of the selected cell, right ?
Note: You don't need any parantheses at all in the above mentioned line.
Love,
Jens