I am new in mac development. I have one problem. I made framework for Aperture that store images on particular place with some other information like username, password, no. of images and ftp server name etc. Then my another application start automatically, that application upload images on ftp server. My problem is how to start uploader application automatically. I think i can use script file and call this script file to first application. Please give me suggestion.
Asked
Active
Viewed 769 times
0
-
You want to start an application automatically when **what** occurs? – trojanfoe Jul 22 '13 at 09:53
-
yes trojanfoe. End of one application, start automatically second application. – Amit Gujjar Jul 22 '13 at 09:55
-
3first_command.sh && second_command.sh in the second write `open -a "Mac application"` – Carlo Jul 22 '13 at 09:58
-
Thanks Carlo. but i m new so plz explain your answer. – Amit Gujjar Jul 22 '13 at 10:04
-
I think you need to use `NSTask` or similar to start an app from your framework. – trojanfoe Jul 22 '13 at 10:11
-
Thanks trojanfoe. How to do this? Please explain this. – Amit Gujjar Jul 22 '13 at 10:13
2 Answers
2
You can use open command with -a option
open -a appName
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/open"];
[task setArguments:[NSArray arrayWithObjects:@"-a",@"appName",nil]];
[task launch];
[task release];

Parag Bafna
- 22,812
- 8
- 71
- 144
-
Thanks Parag Bafna. what is real path of application in this line [task setLaunchPath:@"/usr/bin/open"]? – Amit Gujjar Jul 23 '13 at 13:12
-
-
i give full path like as [task setArguments:[NSArray arrayWithObjects:@"-a",@"/Applications/Uploader.app",nil]], but its not launch. How to launch application? Please help .. – Amit Gujjar Jul 24 '13 at 06:07
-
Open terminal and run ls /Applications/Uploader.app, post output of that command. – Parag Bafna Jul 24 '13 at 06:10
-
@ Parag Bafna, I give this command on terminal "open /Applications/PictageUploader.app/" and application launch. – Amit Gujjar Jul 24 '13 at 06:20
-
-
-
-
0
Thanks trojanfoe and Parag Bafna. My solution is...
NSTask *task = [[NSTask alloc] init];
NSBundle *bundle = [NSBundle bundleWithPath:[[NSWorkspace sharedWorkspace] fullPathForApplication:@"Path Finder"]]];
[task setLaunchPath:[bundle executablePath]];
NSArray *arguments = [NSArray arrayWithObjects:@"Argument1", @"Argument2", nil];
[task setArguments:arguments];
[task launch];
I solve my problem. Thanks to all.

Amit Gujjar
- 683
- 1
- 8
- 20
-
-
Well you basically used Parag Bafna's answer (from a comment I originally posted) so his answer should be accepted. It's not reasonable to post your own answer and accept it using bits of answers provided by others, otherwise where is the motivation to answer at all? You also appear a bit stingy with your upvotes... – trojanfoe Jul 24 '13 at 13:19
-
No i used other link. http://stackoverflow.com/questions/5048677/launching-an-mac-app-with-objective-c-cocoa . – Amit Gujjar Jul 24 '13 at 13:24