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

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.

References: 
 >NSPopUpButton trouble (From: Aaron Boothello <email@hidden>)

  • Prev by Date: adding a new BezelStyle to buttons
  • Next by Date: Re: Installing multiple hotkeys in app
  • Previous by thread: NSPopUpButton trouble
  • Next by thread: Re: NSPopUpButton trouble
  • Index(es):
    • Date
    • Thread