Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *postString = [NSString stringWithFormat:@"username="tango"&password="charlie""];
- NSLog(@"%@",postString);
- //encode post string in supported encoding format in post data
- postData = [postString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
- if(connection)
- return YES;
- else
- return NO;
- [NSMutableRequest setHTTPRequest:urlString];
- [request setURL:url];
- //set HTTP method Post
- [request setHTTPMethod:@"POST"];
- //set HTTP header field with length of post data
- [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
- //set encoding value for HTTP header field
- [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
- //set HTTP body or url request with postData
- [request setHTTPBody:postData];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement