On 13/11/2009, at 2:09 PM, SRD wrote: > When selecting anything off the first menu (item-2 or item-3), the > value of 'sender' prints fine and I can compare it using the code > below. But if I select the first item which is an NSMenu and leads to > another NSMenu with it's item (item-1), then the method menuReader: is > called, but sender does not hold any value at all, it's just blank. > > Anyone understand what I'm doing wrong here? > > - (IBAction) menuReader:(id) sender > { > NSLog(@"sender %@", [sender titleOfSelectedItem]); > > if ([[sender titleOfSelectedItem] isEqualToString:@"item1"]) { > // ... > } > else if ([[sender titleOfSelectedItem] isEqualToString:@"item2"]) { > // ... > } > else if ([[sender titleOfSelectedItem] isEqualToString:@"item3"]) { > // ... > } > } > > Any help much appreciated.
You are calling [sender titleOfSelectedItem], but for the submenu, the sender isn't the pop-up button so it doesn't respond to that message. Why not log what the sender actually is, and you'll see what's going on: NSLog(@"sender: %@", sender); --Graham _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com