Reputation: 879
How can I sanitize URLs made from strings to replace characters like space to %20 and etc?
How can I Print a NSURL in NSLog?
How can I send data to a webserver using POST? i know that for HTML GET:
NSURL * theURL = [[NSURL alloc] initWithString:url];
NSString * results = [NSString stringWithContentsOfURL:theURL];
will do the deal, but what is i am sending over secret data such as username and password?
Upvotes: 0
Views: 1946
Reputation: 96927
An easier framework for running POST requests is Ben Copsey's ASIHTTPRequest kit, which wraps around NSHTTPRequest and adds a lot of useful functionality. It will save you time and it is definitely worth checking out.
Upvotes: 1
Reputation: 13775
The questions changed while I was writing my answer..This is answering how to POST.
You will need to use NSURLConnection.
Upvotes: 1
Reputation: 32316
First off, multiple questions should be asked as multiple questions, but I'll answer anyway:
NSString *escapedString = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"URL is: %@, contents is: %@", myURLObject, [NSString stringWithContentsOfURL:myURLObject]);
POST
data has already been answered in this questionUpvotes: 2