nsurlrequest

Append data to a POST NSURLRequest

烂漫一生 提交于 2019-11-26 02:51:42
问题 How do you append data to an existing POST NSURLRequest ? I need to add a new parameter userId=2323 . 回答1: If you don't wish to use 3rd party classes then the following is how you set the post body... NSURL *aUrl = [NSURL URLWithString:@"http://www.apple.com/"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; [request setHTTPMethod:@"POST"]; NSString *postString = @"company=Locassa&quality=AWESOME!";

How to send json data in the Http request using NSURLRequest

不羁岁月 提交于 2019-11-26 01:44:37
问题 I\'m new to objective-c and I\'m starting to put a great deal of effort into request/response as of recent. I have a working example that can call a url (via http GET) and parse the json returned. The working example of this is below - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:

How to send json data in the Http request using NSURLRequest

六月ゝ 毕业季﹏ 提交于 2019-11-25 18:49:01
I'm new to objective-c and I'm starting to put a great deal of effort into request/response as of recent. I have a working example that can call a url (via http GET) and parse the json returned. The working example of this is below - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog([NSString stringWithFormat:@