I have a view with an UIImageView. It was loaded with either jpg or png image format. Says the jpg image version has a data size of 100k. I then used NSKeyedArchiver to save my view to a file. The size of the file is getting about 3MB. If I used the png version of the image, the archived file is still around 3MB.
I then used zlib to compress the archived file. But it does not seem to have much effect.
Anything I can do to get it back to close as much as possible the 100k area?
BTW: If I used UIWebView to load the image, then with the jpg version of image I will get the archived file's very close to the original jpg's.
EDIT: Matt's answer gave me an idea, so this was what I ended up doing:
Note: my I arleady used a subclass of UIImageView
- Create an iVar to hold
NSDatafor the image - in
encodeWithCoderbefore calling[super encodeWithCoder...], setself.image = nil; and setself.imageback to the image data using the savedNSDatain 1. - make sure encode the
NSDataiVar in 1.
In the initWithCoder, using the NSData iVar to restore the image.