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)
}
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)