0

I found some related posts:

UIImagePickerControllerDelegate to Swift?

how to capture camera with UIImagePickerController in swift?

But none of them works for beta 3 because the UIImagePickerControllerDelegate changed:

func imagePickerController(picker: UIImagePickerController!, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]!)

My question is how to get UIImage object from info Array? Thanks

Kai Huppmann
  • 10,705
  • 6
  • 47
  • 78
Bagusflyer
  • 12,675
  • 21
  • 96
  • 179

1 Answers1

5

Its a dictionary, index it with UIImagePickerControllerOriginalImage

let image = info[UIImagePickerControllerOriginalImage] as UIImage
Jack
  • 16,677
  • 8
  • 47
  • 51
  • I just found this too after try and error. Thanks. let img : UIImage = info[UIImagePickerControllerOriginalImage] as? UIImage – Bagusflyer Jul 16 '14 at 16:39
  • Edited to include the casting. You shouldn't need `as?` since it will always be an image. – Jack Jul 16 '14 at 16:41
  • Yes. That's right. Actually my real code is inside a if statement so that as? is included. – Bagusflyer Jul 16 '14 at 23:22