Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Json Request in iphone
- NSString *postStr = [NSString stringWithFormat:@"username=%@&password=%@", username, password];
- NSData *postData = [postStr dataUsingEncoding:NSUTF8StringEncoding];
- NSMutableURLRequest *requesting = [[NSMutableURLRequest alloc] initWithURL:YourURLObject];
- [requesting setHTTPMethod:@"POST"];
- [requesting setValue:[NSString stringWithFormat:@"%d", [postData length]] forHTTPHeaderField:@"Content-Length"];
- [requesting setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
- [requesting setHTTPBody:postData];
- NSError *error;
- NSHTTPURLResponse *response;
- [NSURLConnection sendSynchronousRequest:requesting returningResponse:&response error:&error];
- NSArray *credentials = [NSArray arrayWithObjects:@"uName", @"pWord",nil];
- NSString *jsonString = [credentials JSONString];
- NSDictionary *credentials = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"uName", @"pWord",nil] forKeys:[NSArray arrayWithObjects:@"UserName",@"password",nil]];
- NSString *jsonString = [credentials JSONString];
Add Comment
Please, Sign In to add comment