title: UIImagePickerController Edited Image - Convert NSRect to CGRect in Swift 2
body: <p>I'm trying to crop an image that has been selected and edited through the UIImagePicker. For some reasons the picker doesn't return a <code>UIImagePickerControllerEditedImage</code> value. So what I'm trying to do is to get the original value and crop it according to the rectangle in <code>UIImagePickerControllerCropRect</code> but that's a <code>NSRect</code> and I need to convert it to a <code>CRRect</code> to crop it. This is my image picker controller function : </p>
  
  <pre><code>func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
          //Cut photo or show subview
          let chosenImage : UIImage
          print(editingInfo)
          if let possibleImage = editingInfo!["UIImagePickerControllerEditedImage"] as? UIImage {
              print("Edited image")
              chosenImage = possibleImage
  
          } else if let possibleImage = editingInfo!["UIImagePickerControllerOriginalImage"] as? UIImage {
              print("Non edited image")
  
              if let rectangle = editingInfo!["UIImagePickerControllerCropRect"] as? [[Int]] {
  
                  print(rectangle[0])
  
              }
  
              let rect: CGRect = CGRectMake(0, 230, 750, 750)
  
  
              let imageRef: CGImageRef = CGImageCreateWithImageInRect(possibleImage.CGImage, rect)!
  
              let image: UIImage = UIImage(CGImage: imageRef, scale: image.scale, orientation: image.imageOrientation)
              chosenImage = image
          } else {
              return
          }
  
  
          self.profilePicture.image = chosenImage.rounded?.circle
          dismissViewControllerAnimated(true) { () -&gt; Void in
  
          //update the server
          }
      }
  </code></pre>
  
  <p>Everything else works fine except it crops the image according to the rectangle in <code>CGRectMake(0, 230, 750, 750)</code> I'd like to make that instead of fixed values the values of <code>UIImagePickerControllerCropRect</code> . Please let me know if you have any suggestion on how to get that.</p>
  
  <p>Thank you!</p>