0 < -1 !!
0 < -1 !!
- Subject: 0 < -1 !!
- From: Jerry LeVan <email@hidden>
- Date: Thu, 22 Jul 2004 22:48:03 -0400
Just squandered the evening fiddling with code that looked like
- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem
{
// Disable next and previous menu items as
// necessary
if ([menuItem action] == @selector(next:)) {
return (currentIndex < [executedStatements count] - 1);
}
if ([menuItem action] == @selector(previous:)) {
return (currentIndex > 0);
}
return YES;
}
executedStatements is a NSMutableArray.
When currentIndex was zero and [excutedStatements count] was zero
the method was returning YES ie 0 < -1 is true !
if I set int t1 = currentIndex and int t2 = [executedStatements count]
-1
and then returned ( t1 < t2) I got the right answer...
After squandering several hours ( it took a while to see what the
problem was).
I Read The Fine Manual and it told me that the count method returns an
"unsigned"
I guess I have to go back and review how expressions are evaluated.
The fix was....
currentIndex < (int)[executedStatements count] - 1
Jerry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.