-5

I get this error when calling my delegate method for my ImagepickerViewController

Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

My delegate method is

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
{

    if let image = info[UIImagePickerControllerOriginalImage] as? UIImage
    {
         UserDefaults.standard.set(UIImagePNGRepresentation(image), forKey: "avatarImage")
    }
    else
    {
        //Error message
    }
    self.dismiss(animated: true, completion: nil)
}

Edit: I tried the other questions answers, and they did not work

  • 3
    Possible duplicate of [PhotoPicker discovery error: Error Domain=PlugInKit Code=13](https://stackoverflow.com/questions/44465904/photopicker-discovery-error-error-domain-pluginkit-code-13) – Quoc Nguyen Apr 04 '18 at 01:27
  • 1
    Do not store image data in UserDefaults. Write the image to a file. – rmaddy Apr 04 '18 at 01:27

1 Answers1

-1

You need to add an @objc and make explicit Objective-C reference:

@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
Xcoder
  • 1,433
  • 3
  • 17
  • 37