I just got an isolated crash report for imagePickerController:picker: didFinishPickingMediaWithInfo
with an EXC_BREAKPOINT
message (which I understand typically occurs when force-unwrapping a nil value). The code that crashed is:
public func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
let pickedImage = info[UIImagePickerControllerOriginalImage] as! UIImage
dismissViewControllerAnimated(true, completion: nil)
picker.delegate = nil
// ...do something with pickedImage...
}
I assume I need to check that a UIImage has been returned like this:
public func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
dismissViewControllerAnimated(true, completion: nil)
picker.delegate = nil
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
// ...do something with pickedImage...
}
else {
// Show unsupported media type error dialog
}
}
I have the picker media types set to image:
picker.mediaTypes = [kUTTypeImage as String]
So I am surprised didFinishPickingMediaWithInfo
is returning something other than a UIImage. Any ideas why or what might be returning?