NSTask isn't working; I think it has to do with the arguments. Here is my code:
- (IBAction)downloadFile:(id)sender {
// allocate our stuff :D
progressIndication = [[NSProgressIndicator alloc] init];
NSTask *downloader = [[NSTask alloc] init];
// set up the downloader task
[downloader setLaunchPath:@"/usr/bin/curl"];
[downloader setArguments:[NSArray arrayWithObject:[NSString stringWithFormat:@"-LO %@", downloadURL]]];
// go to the Desktop!
system("cd ~/Desktop");
// start progress indicator
[progressIndication startAnimation:self];
// download!
[downloader launch];
// stop the progress indicator, everything is done! :D
[progressIndication stopAnimation:self];
}
Thanks
You really don't need to use
curlto do this; just useNSDatato accomplish the task much more easily:If you insist you need to use
curlfor this, you're going to have to fix your code, which doesn't work for several reasons. First and foremost, your arguments are wrong. You should have the following code:Second,
system("cd ~/Desktop")is meaningless; get rid of it.Lastly,
NSTaskruns concurrently.[downloader launch]starts the operation, and your code continues. It should be: