I'm trying to figure out how to pass a variable (in my case hostname) to a function i created from a programatically inserted "menu item".
#function
-(void)goToTerminal:(NSString *)hostname {
NSString *s = [NSString stringWithFormat:@"tell application \"Terminal\" to do script \"ssh root@%@\"", hostname];
NSAppleScript *as = [[NSAppleScript alloc] initWithSource: s];
[as executeAndReturnError:nil];
}
# adding menu item in another function
[NSString *hostname = [NSString stringWithString:@"some.host"]];
NSMenuItem *subhostline = [[[NSMenuItem alloc] initWithTitle:sshtohost action:@selector(goToTerminal:) keyEquivalent:@""]autorelease];
[subhostline setTarget:self];
Thankyou! D.