Here is the full error:
Objective-C method 'imagePickerController:didFinishPickingMediaWithInfo:' provided by method
'imagePickerController(_ :didFinishPickingMediaWithInfo:)'
conflicts with optional requirement method 'imagePickerController(_:didFinishPickingMediaWithInfo:)'
in protocol 'UIImagePickerControllerDelegate'
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]){
if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
ImageView.contentMode = .ScaleAspectFit
ImageView.image = pickedImage
}
dismissViewControllerAnimated(true, completion: nil)
}
The correct function head is:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
<#code#>
}
Note the String
instead of NSObject
in the declaration of the info dictionary.
I am not sure to why the docs are saying that you have to write NSObject
, but String
is the correct one.
If you implement any protocol methods I would recommend using the auto completion of Xcode to make sure that you don't run into problems like this.
I am unsure where Xcode gets that auto completion from but it appears to always be in sync with the actual compiler which in the end is the one thing you have to worry about rather than some online apple docs! Especially in times when the frameworks are constantly changing and even the language itself is under development.