Hi i have a imageview and a button underneath which is called upload. When the user clicks on the button upload they can access there gallery and choose an image to set to the image view. When i close the app the image that has been set keeps disappearing. I was wondering i would have to use user defaults to save the image locally but i am not sure how to do this. I have provided my code down below.
image
var image:UIImageView = {
    let image = UIImageView()
    image.translatesAutoresizingMaskIntoConstraints = false
    image.backgroundColor = .black
    return image
}()
image picker controller
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    if let uploadedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage
    {
 
        image.image = uploadedImage
        
        
        
    }else{
        
    }
    self.dismiss(animated: true, completion: nil)
}   
 
    