How to send json post values to a remote server an

2019-03-05 17:18发布

问题:

I'm new to IOS 5 and I'm trying to send json values to a remote php server, which will send me back the results. This is my dispach call so far:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    NSData* data = [NSData dataWithContentsOfURL: http://www.someurl/example.php];
    [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
});

I know this is mainly a GET request. How can I send post values? Any help would be appreciated, thanks!

回答1:

You will have to resort to NSURLRequest (or another request object) to do a POST. Try this question, Append data to a POST NSUrlRequest, as an example of how to send data and handle the result.



标签: ios json http post