I am making a small app where the user can create a game profile, input some data and a picture that can be taken with the camera.
I save most of that profile data with the help of NSUserDefaults
, but a friend discouraged me from saving the profile image in NSUserDefault
.
What's the proper way to save and retrieve images locally in my app?
One way to do this is use the application's document directory. This is specific to a application and will not be visible to other applications.
Hope it Helped..How to create this:
Just add a static function to App Delegate and use the function where ever the path is required.
I think this("iphone-user-defaults-and-uiimages") post addresses your issue. Don't save blobs to a property list such as NSUserDefaults. In your case I would write to disk directly instead.
You should save it in
Documents
orCache
folder. Here is how to do it.Saving into
Documents
folder:Loading from
Documents
folder:You can also use
UIImageJPEGRepresentation
to save yourUIImage
as aJPEG
file. What's more if you want to save it inCache
directory, use: