0

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

7 Comments

It's not obsolete, so much as totally awful. You really don't want to be calling out to the shell for a networking call. Listen to H2CO3's wise words!
can you please explain it briefly? I didn't get anything.
@AKV Oh thanks. Well, I don't see any particular reason to involve another extra level of abstraction.
@Rox You don't know how to call a function or what?
I don't know about libcurl. How to use it?
|
0

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];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.