Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you're looking for is NSMutableURLRequest and the addValue:forHTTPHeaderField method.</p> <p>Create the request with the URL you wish to communicate with. Load the values you wish to transmit into the header or into the HTTPBody, set your HTTPMethod and then use a NSURLConnection method to send and receive the response. </p> <p>As for an array with the information you could simply enumerate through the array and add the values to the HTTPHeaderFields. It really depends on what the server is setup to receive.</p> <p><a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html#//apple_ref/doc/uid/10000165i" rel="nofollow">http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html#//apple_ref/doc/uid/10000165i</a></p> <p>Has more information.</p> <pre><code>NSString *urlString = @"http://yoururl.com"; NSURL *url = [NSUL URLWithString:urlString]; NSMutalbeURLRequest *request = [NSMutableURLRequest requestWithURL:url]; NSDictionary *headerInformation = [NSDictionary dictionaryWithObjectsAndKeys:@"1",@"id",@"John",@"name",@"100",@"score", nil]; for (NSString *key in [headerInformation allKeys]) { [request addValue:[dict valueForKey:key] forHTTPHeaderField:key]; } NSHTTPURLResponse *response = nil; NSError *error = nil; // this will perform a synchronous GET operation passing the values you specified in the header (typically you want asynchrounous, but for simplicity of answering the question it works) NSData *responseData = [NSURLConnection sendSynchronousRequest:request reuturningResponse:&amp;response error:&amp;error]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"Response: %@", responseString); [responseString release]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload