title: How can I get the CLLocation of a photo selected from UIImagePickerController in Swift?
body: <p>UIImagePickerController selects an image from the user's photo library, </p>
  
  <p>I'd just like to get the coordinates of the location of the selected photo, in Swift...</p>
  
  <p>I have tried things like trying to get the photo's url....</p>
  
  <pre><code>func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
      let imageURL = editingInfo![UIImagePickerControllerReferenceURL] as! NSURL
      self.imageFromAsset(imageURL)
  }
  </code></pre>
  
  <p>and passing that to...</p>
  
  <pre><code>func imageFromAsset(nsurl: NSURL) {
      let asset = PHAsset.fetchAssetsWithALAssetURLs([nsurl], options: nil).firstObject as! PHAsset
      var location = asset.location   //then do something with this data
  }
  </code></pre>
  
  <p>but getting the image url to begin with creates a fatal error.</p>
  
  <p>Hope someone can help, thank you.</p>
  
  <p>Error message:</p>
  
  <pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
  (lldb) 
  </code></pre>
  
  <p>This error appears to occur on this line:</p>
  
  <pre><code>    let imageURL = editingInfo![UIImagePickerControllerReferenceURL] as! NSURL
  </code></pre>