Load a saved image

I am using Swift4 and Xcode.
I have a view where the user types in their name, age and also they can add a picture. When they click save all gets saved then when you reopen app there is now a load button if you want to load that user. The name and age load back but I cannot get the saved picture to reload.
Any thoughts on how to bring back the picture that was saved?
Thanks

@drewgost Thanks very much for your question!

The first thing I would ask is, how are you saving your data? Are you using Core Data or are you using NSUserDefaults, or some other mechanism? More than likely if you are using some form of persistence, then my first advice would be to check to see if in fact you are saving the image correctly. After verifying that you are indeed saving the image correctly, then I would ask, are you retrieving the image correctly from storage? Those are the initial steps I would take to try and see why my image isn’t loading with the rest of my data.

I hope this helps!

All the best!

Hello Syedfa and thank you for your comments. Yes I am using NSUserDefaults to save the image and it is working as I can go in and find it in my photos. But I do realize now that I am also saving it to my UIImageWriteToSavedPhotosAlbum. So I think this is where the problem arises. I may not be saving it to the NSUserDefaults properly and the reason why it does not pull up with the rest of the data when I call it.
I will look deeper into the NSUserDefaults saving and loading an image.
I appreciate your pointing me into looking at the issue properly.

Have a great day

@drewgost I’m happy I was able to help!

All the best!

This topic was automatically closed after 166 days. New replies are no longer allowed.