Store image in NSUserDefaults and Retrieve it.

Store image in NSUserDefaults and Retrieve it

 What are NSUserDefaults?.

  NSUserDefault is a lightweight storage section where the user can save their persistent data. NSUserDefault Storing the data in the form of key and value pairs. NSUserDefault is very easy, You don’t need to fetch any queries, path, and files.we can access it in a single line of code. NSUserDefault, not temporary data storage. its persistent data storage you can access data after the reboot of the cell phone itself. Here an example of storing the image in NSUserDefault.

Storing image into NSUserDefault:

Convert Image into NsData,store NSData into an NSUserDefault.
Code:

Retrieving image from NSUserDefault:

Get data into the NSData form. Add it to UIImage.
Code:

Thank you.Please comment and share the article if you find something useful. Happy Coding..

1 thought on “Store image in NSUserDefaults and Retrieve it.”

Leave a Comment