I have an NSTableView and in one cell I have an NSPopUpButton... ok. I want to set the selected item in the pop up button based on a value but no matter what I do I can't seem to set which menu item gets selected...
What I need is if p.status is "Approved" then set the menu item in "statusMenu" to "Approved" but it just doesn't work. I have the bindings set correctly (I think) the pop up button is bound to "statusMenu" and if I setup a breakpoint I can view the menu correctly... I can also retrieve the value of the selected menu item and it logs correctly to "Approved" but the actual popup button doesn't change...
here's the code:
NSTableCellView *cell = [table_view makeViewWithIdentifier:identifier owner:self];
if([identifier isEqualToString:@"status"]){
if(p){
for (NSView *subview in cell.subviews) {
if (![subview isKindOfClass:[NSButton class]]) continue;
if ([subview.identifier isEqualToString:@"statusMenu"]){
if ([p.status isEqualToString:@"Approved"]){
[(NSButton *)subview setStringValue:@"Approved"];
[statusMenu selectItemWithTitle:@"Approved"];
NSLog(@"selected: %@", [statusMenu titleOfSelectedItem]); //the Log is "Approved" but the pop up button doesn't change...!!
}
}
}
}
}
Here's my header:
@interface ProposalTableViewController : NSObject<NSTableViewDataSource, NSTableViewDelegate, QLPreviewPanelDelegate, QLPreviewPanelDataSource>{
@public
//A bunch of other stuff that's not relevlant
IBOutlet NSPopUpButton *statusMenu;
}
Here are my bindings...