0

Is it possible to send text from an xcode input and have the data sent through a php function?

1
  • 2
    This question doesn't make sense. Please rephrase. Commented Sep 19, 2010 at 18:38

2 Answers 2

3

If you actually want to do this using simple Objective-C (Foundation) classes, you should use NSURLConnection. Example:

NSString * post = [[NSString alloc] initWithFormat:@"&myvariable=%@", myString];
NSData * postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
NSString * postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest * request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.yoursite.com/file.php"]]]; 
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection * conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

if (conn) NSLog(@"Connection Successful");
Sign up to request clarification or add additional context in comments.

Comments

0

You can use this to post data from your xCode app to a web server.

http://allseeing-i.com/ASIHTTPRequest/

1 Comment

The library is no longer worked on and the webpage recommends that you use something else.

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.