How to store an image using NSData in Objective C
-
16-09-2019 - |
Question
How do I take a UIImage and store it preferably as NSData (to write to a file)? Is there some obvious method out there, or could someone provide a code snippet?
Thanks in advance!
PS. My next question will probably be for a code snippet to capture the current screen image. The snippets I've seen so far appear to be serious overkill for what I need.
Solution
You can serialize a UIImage using UIImagePNGRepresentation()
or UIImageJPEGRepresentation()
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow