NSPopUpButton Problem
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]