iosswiftuiimageviewsave-image

i did Choose an image from camera or gallery and how to save that image to display in other View?


I did everything of getting image from camera or gallery, But how to save that image in array or in realm data to display in other viewController.

How can i do it?

Program :-

 //Camera to save image and display later
 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

    showImage.image = info[UIImagePickerController.InfoKey.originalImage]
    imagePicker.dismiss(animated: true, completion: nil)

   }

Solution

  • You can save image as Data, let's say you have pickedImage.

    let imageData = pickedImage.pngData()
    

    save imageData to realm.

    To get image

    let savedImage = UIImage(data: imageData)