Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The simplest way is to use the <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html" rel="nofollow noreferrer">NSURLConnection</a> <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html#//apple_ref/occ/clm/NSURLConnection/sendSynchronousRequest:returningResponse:error:" rel="nofollow noreferrer">sendSynchronousRequest:returningResponse:error:</a> method.</p> <p>e.g.</p> <pre><code>NSURLResponse *response; [NSURLConnection sendSynchronousRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: @"http://webservice.com/?log=1"]] returningResponse: &amp;response error: NULL]; </code></pre> <p>The downside to using this method is that it will hang your app while it's performing the URL request. To do this request asynchronously you need to use the <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html#//apple_ref/occ/clm/NSURLConnection/connectionWithRequest:delegate:" rel="nofollow noreferrer">connectionWithRequest:delegate:</a> method. This gets a little more complex as you need to provide a delegate (in your case, one that does nothing).</p> <p>e.g.</p> <pre><code> [[NSURLConnection connectionWithRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: @"http://webservice.com/?log=1"]] delegate:self] retain]; ... - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [connection release]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; } </code></pre> <p>See <a href="http://developer.apple.com/iphone/library/samplecode/SimpleURLConnections/Introduction/Intro.html" rel="nofollow noreferrer">SimpleURLConnections</a> for more examples of using NSURLConnection.</p> <p>UPDATE: removed optional delagate methods as per David's comment.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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