title: Return value from completion handler - Swift
body: <p>I'm using a loadImage method in a Utilities class and am having some trouble with returning images via closures. Basically because my code could return either an image or an error, assigning it to an image property when the method is called will not work.</p>
  
  <p>Is the approach I'm using wrong in the method declaration of the class, or should I be calling the method differently to anticipate potentially differing results? Thanks</p>
  
  <pre><code>public class UtilitiesService: NSObject {
      public class func loadImage(urlString:String)
      {
  
      var imgURL: NSURL = NSURL(string: urlString)!
      let request: NSURLRequest = NSURLRequest(URL: imgURL)
      NSURLConnection.sendAsynchronousRequest(
          request, queue: NSOperationQueue.mainQueue(),
          completionHandler: {(response: NSURLResponse!,data: NSData!,error: NSError!) -&gt; Void in
              if error == nil {
                  self.returnImage(data)
              }
      })
  }
  
  public class func returnImage(imageData: NSData) -&gt; UIImage {
  
      return UIImage(data: imageData)!
  
  }
  }
  
  //// view controller
  class someView: UIViewController {
  var image.image = loadImage(url) ///will throw a return type error
   }
  </code></pre>