I am trying to get a photo from the system album and using below code:
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
picker.dismiss(animated: true, completion: nil)
// var image: UIImage? = info[UIImagePickerController.InfoKey.editedImage.rawValue] as? UIImage
guard var image = info[.originalImage] as? UIImage else { return }
// var image = info.index(forKey: UIImagePickerController.InfoKey.editedImage.rawValue) as? UIImage
if (image == nil ) {
// image = info[UIImagePickerControllerOriginalImage] as? UIImage
image = info.index(forKey: UIImagePickerController.InfoKey.originalImage.rawValue) as? UIImage
}
But the xcode always warns me:
“Cannot subscript a value of type '[String : Any]' with an index of type 'UIImagePickerController.InfoKey'”
I don't know how to change to continue.