title: UIImagePickerController camera provides no URL
body: <p>I've got an app I'm working on that up until a couple days ago only allowed someone to upload a photo from their photo library.  It works perfectly, and checks the metadata for GPS coordinates and makes a conditional comparison.</p>
  
  <p>Now, however, I decided I'd like to let them snap a photo through the app, and have run into a snag.  The code that worked for the photo picking isn't working so well when using the camera.</p>
  
  <p>Here's my original code for a button to upload a photo:</p>
  
  <pre><code>    @IBAction func pickPhoto(sender: AnyObject) {
      if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum) {
          imageView.hidden = true
  
          let imagePicker = UIImagePickerController()
          imagePicker.delegate = self
          imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum
          imagePicker.allowsEditing = false
  
          presentViewController(imagePicker, animated: true, completion: nil)
      }
  }
  </code></pre>
  
  <p>and then here's the UIImagePickerController:</p>
  
  <pre><code>    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
  
      imageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
  
      println("imagePickerController")
  
      let library = ALAssetsLibrary()
  
      let url: NSURL = info[UIImagePickerControllerReferenceURL] as! NSURL
  
      library.assetForURL(url, resultBlock: {
          (asset: ALAsset!) in
  
          if  asset.valueForProperty(ALAssetPropertyLocation) != nil {
  
              println("!= nil")
              let imageLongitude = (asset.valueForProperty(ALAssetPropertyLocation) as! CLLocation!).coordinate.longitude
              let imageLatitude = (asset.valueForProperty(ALAssetPropertyLocation) as! CLLocation!).coordinate.latitude
  
              println("imageLatitude = \(imageLatitude)")
              println("imageLongitude = \(imageLongitude)")
  
              println("Starting the Location check")
  </code></pre>
  
  <p>... and it goes on from there to do more checking.</p>
  
  <p>I copied my pickPhoto button and turned it into a takePhoto button, like so:</p>
  
  <pre><code>    @IBAction func takePhoto(sender: AnyObject) {
      if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
          imageView.hidden = true
  
          let imagePicker = UIImagePickerController()
          imagePicker.delegate = self
          imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
          imagePicker.allowsEditing = false
  
          presentViewController(imagePicker, animated: true, completion: nil)
      } else {
  
          notifyUser("No Camera", message: "This device doesn't have a camera!")
      }
  }
  </code></pre>
  
  <p>and that opens up the camera and lets me take a photo.  However, when I use the photo, I immediately get a crash in the UIImagePickerController on this line:</p>
  
  <pre><code>let url: NSURL = info[UIImagePickerControllerReferenceURL] as! NSURL
  </code></pre>
  
  <p>I'm assuming that's because as a camera image, it's technically not saved anywhere, therefore it has no URL or path.</p>
  
  <p>So my question is, how do I save the image (temporarily or in the camera roll), keeping the GPS metadata intact from the camera (assuming Location Services are active), so I can pass it along and have it play nice?</p>