Rox
Rox

Reputation: 909

Calling curl command in Objective C

I want to call this cURL command in my iPhone app.

curl --user "username:PASSWD" https://api.github.com/users/username

How can I execute it in objective C? I tried many methods but didn't succeed. Please help me to solve my problem.

Upvotes: 0

Views: 888

Answers (2)

Anoop Vaidya
Anoop Vaidya

Reputation: 46563

NSTask will not work under sandbox environment (you will get "deny process-fork"). So put your application into /Applications

You can use NSTask for executing any system commands.

NSTask *task=[NSTask new];
[task setLaunchPath:@"curl --user "username:PASSWD" https://api.github.com/users/username"];
[task launch];

Upvotes: 0

user529758
user529758

Reputation:

To invoke a comand using the shell, use the system() function:

system("curl --foo --bar");

However, do not do this. It's a hack. Use libcurl or the NSURL API for networking. You may as well use libgit2 for checking out git repositories.

Upvotes: 3

Related Questions