Re: NSPopUpButton trouble
Re: NSPopUpButton trouble
- Subject: Re: NSPopUpButton trouble
- From: p3consulting <email@hidden>
- Date: Sun, 4 Jan 2004 13:09:02 +0100
Aaron,
Where is selFlag initialized ?
Should not it be
[myPopUpButton selectItemAtIndex: selected];
?
Should not you be careful about no item selected at all ?
int selected = -1 ;
...
if (selected >= 0)
[myPopUpButton selectItemAtIndex: selected];
or
int selected = kMY_DEFAULT_ITEM ; // define kMY_DEFAULT_ITEM somewhere
to something useful and always valid
...
[myPopUpButton selectItemAtIndex:selected];
Pascal Pochet
P3 Consulting
On 4 janv. 2004, at 11:55, Aaron Boothello wrote:
I'm using a drop down menu via NSPopUpButton in my App.
i update the menu using the following pseudo code:
-(void)updateMyPopUpButton
{
int x,selected;
[myPopUpButton removeAllItems];
for(x = 0;x<[mySuperModel getModelCounter];x++)
{
[myPopUpButton addItemWithTitle:(NSString *)[object[x] getTitle]];
if([object isObjectSelected])
selected = x;
}
[myPopUpButton selectItemAtIndex:selFlag];
}
here's the problem:
the last line of the code is where the app ALWAYS crashes, i comment
it out and all is well. but id like to know why this is happening, and
how to correct it.
Cheers,
Aaron.
_______________________________________________
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.
_______________________________________________
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.