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
NSData
for the image - in
encodeWithCoder
before calling[super encodeWithCoder...]
, setself.image = nil
; and setself.image
back to the image data using the savedNSData
in 1. - make sure encode the
NSData
iVar in 1.
In the initWithCoder
, using the NSData
iVar to restore the image.