how to pass arguments to NSMenu selector ?
how to pass arguments to NSMenu selector ?
- Subject: how to pass arguments to NSMenu selector ?
- From: Dharmendra <email@hidden>
- Date: Thu, 12 Jun 2008 18:30:33 +0530
I have a dynamic menu items generated based on some online information. Next I want is to link them to their respective online info pages. So I tried to use the following procedure, but it doesn' work :
nodes = array of NSXMLdocument ...
for(i=0;i<[nodes count];i++) {
NSString *nodeTitle = ...;
NSURL * nodeURL = ...;
[menu insertItemWithTitle:nodeTitle action:@selector(connectNode:) keyEquivalent:@"" atIndex:i];
[[menu itemAtIndex:i] setTarget:self];
}
-(void)connectNode:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:nodeURL];
}
My assumption was that nodeURL used in connectNode selector would be unique for each calls, but it uses the last assigned value of nodeURL for all menu items. That is because the selector is different from a typical function.
Now, how do you pass arguments to selectors when you want to display dynamic information in menubar?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden