• 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
NSPopUpButton Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPopUpButton Problem


  • Subject: NSPopUpButton Problem
  • From: Mark T <email@hidden>
  • Date: Fri, 13 Jul 2001 16:10:52 -0400

I'm having a little bit or trouble with NSPopUpButton's addItemWithTitle method. Either it's not implemented correctly or I'm not using it correctly. In the code below, the first time that the method is called, it seems to work appropriately. j is updated from 0 to 1 and setEnabled works correctly. The second time through the loop, however, j is not incremented from 1 to 2 and itemAtIndex crashes the program with the errors following the code snippet. Am I doing something wrong, or is this method broken?

Mark T.

theButton = [self aPopUpButtonMadeInInterfaceBuilder];
[theButton setAutoenablesItems:NO];
[theButton removeAllItems];
j = [[theButton itemArray] count]; //for debugging purposes only
for(i = 0; i < NUMBER_OF_VARIABLES; i++)
{[theButton addItemWithTitle:@"Disabled Item"];
j = [[theButton itemArray] count]; //for debugging purposes only
[[theButton itemAtIndex:i] setEnabled:NO];}

*** Assertion failure in -[NSMenu itemAtIndex:], NSMenu.m:552
An uncaught exception was raised
Invalid parameter not satisfying: (index >= 0) && (index < [_itemArray count])
*** Uncaught exception: <NSInternalInconsistencyException> Invalid parameter not satisfying: (index >= 0) && (index < [_itemArray count]


  • Follow-Ups:
    • Re: NSPopUpButton Problem
      • From: j o a r <email@hidden>
References: 
 >Re: NSString, NSArray, get the characters of one of the NSString in an Array of NSStrings? (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: NSString, NSArray, get the characters of one of the NSString in an Array of NSStrings?
  • Next by Date: Re: Status of @"" strings
  • Previous by thread: Re: NSString, NSArray, get the characters of one of the NSString in an Array of NSStrings?
  • Next by thread: Re: NSPopUpButton Problem
  • Index(es):
    • Date
    • Thread