UIImagePickerControllerEditedImage //Unable to use index type as “UIImagePickerController.InfoKey” type'[String: Any]’ subscript
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
self.userProfileImage.contentMode = .scaleAspectFit
self.userProfileImage.image = pickedImage
}
picker.dismiss(animated: true, completion: nil)
}
func imagePickerController(_ picker:UIImagePickerController,didFinishPickingMediaWithInfo info:[UIImagePickerController.InfoKey:Any])
You should see a warning with the name of func Message
Instance method
‘imagePickerController(:didFinishPickingMediaWithInfo:)’ nearly
matches optio nal requirement
‘imagePickerController(:didFinishPickingMediaWithInfo:)’ of protocol
‘UIImagePickerControllerDelegate’Candidate has non-matching type'(UIImagePickerController, [String :
Any] ) -> ()’Move’imagePickerController(_:didFinishPickingMediaWithInfo:)’ to
another extension to silence this warningMake’imagePickerController(_:didFinishPickingWithInfo:)’ private
to silence this warningRequirement’imagePickerController(_:didFinishPickingMediaWithInfo:)’ declared here (UIKit.UIImagePickerControllerDelegate)
Trying to pass the chat client from swift 4 to swift 4.2 and using the selector I found trouble.
UIImagePickerControllerEditedImage //Cannot use type with index type “UIImagePickerController.InfoKey”‘[String :Any]’subscript
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {< br /> self.userProfileImage.contentMode = .scaleAspectFit
self.userProfileImage.image = pickedImage
}
picker.dismiss(animated: true, completion: nil)
}
The method signature has been changed to
func imagePickerController(_ picker:UIImagePickerController,didFinishPickingMediaWithInfo info:[UIImagePickerController.InfoKey :Any])
You should see a warning message with the name of func
Instance method
‘imagePickerController(:didFinishPickingMediaWithInfo :)’ nearly
matches optional requirement
‘imagePickerController(:didFinishPickingMediaWithInfo:)’ of protocol
‘UIImagePickerControllerDelegate’Candidate has non-matching type'(UIImagePickerController, [String :
Any]) -> ()’Move’imagePickerController(_:didFinishPickingMediaWithInfo:)’ to
another extension to silence this warningMake ‘ imagePickerController(_:didFinishPickingMediaWithInfo:)’ private
to silence this warningRequire ment ‘imagePickerController(_:didFinishPickingMediaWithInfo:)’ declared here (UIKit.UIImagePickerControllerDelegate)