views:

671

answers:

2

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.

+5  A: 

You can serialize a UIImage using UIImagePNGRepresentation() or UIImageJPEGRepresentation().

Dave R
Thanks Dave! I crossed paths with those earlier but mistook them as being something else; would never have revisited them if you didn't point them out again. Code working - very pleased!
A: 

Hi can you help me about this topic? I faced with same problem. I want to encode png image to NSData and decode it again.. Thank you in advance

sarah rose