Reputation: 909
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
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
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