• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
0 < -1 !!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: 0 < -1 !!
      • From: Nicko van Someren <email@hidden>
    • Re: 0 < -1 !!
      • From: John <email@hidden>
  • Prev by Date: Re: X windows display and fast user switching
  • Next by Date: Sending Shell Commands
  • Previous by thread: Re: Adding Bindings to NSOutlineView versus a horrible hack
  • Next by thread: Re: 0 < -1 !!
  • Index(es):
    • Date
    • Thread