Re: NSPopUpButton trouble
Re: NSPopUpButton trouble
- Subject: Re: NSPopUpButton trouble
- From: Aaron Boothello <email@hidden>
- Date: Mon, 05 Jan 2004 00:33:52 +0800
Oh,
i do do all the error checking making sure that selFlag is between 0 and [mySuperModel getModelCounter]. and selFlag is declared in the same method. i hadnt done the error checking before, and put it in as well, but the same problem turns up.
And other ideas guys?
Cheers,
Aaron.
On Sunday, January 04, 2004, at 08:09PM, p3consulting <email@hidden> wrote:
>
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.
_______________________________________________
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.