Skip to content

Instantly share code, notes, and snippets.

@toranb
Created April 11, 2011 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toranb/912882 to your computer and use it in GitHub Desktop.
Save toranb/912882 to your computer and use it in GitHub Desktop.
HttpWithObjectiveCViewController.m
- (void) viewDidLoad
{
NSURL *url = [NSURL URLWithString:@"http://toranbillups.com/phone/AddSuggestion"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSData *requestData = [@"name=testname&suggestion=testing123" dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPMethod:@"POST"];
[request setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment