title: How do I call a webservice in Swift?
body: <p>How do I call a RESTful web service in Swift?  In Objective C I've used the following code, but haven't been able to find details of how to do the same in swift.</p>
  
  <pre><code>- (IBAction)fetchData;
  {
  NSURL *url = [NSURL URLWithString:@"http://myrestservice"];
  NSURLRequest *request = [NSURLRequest requestWithURL:url];
  [NSURLConnection sendAsynchronousRequest:request
                                     queue:[NSOperationQueue mainQueue]
                         completionHandler:^(NSURLResponse *response,
                                             NSData *data, NSError *connectionError)
   {
       if (data.length &gt; 0 &amp;&amp; connectionError == nil)
       {
           NSDictionary *response = [NSJSONSerialization JSONObjectWithData:data
                                                                    options:0
                                                                      error:NULL];
           self.content.text = [[response objectForKey:@"text"] stringValue];
       }
   }];
  </code></pre>
  
  <p>}</p>