Why we did binary write for UIImage?


#1

In this chapter, we are first introduced to archiving. Then the allItems array
is written to filesystem using archiving.

There is a separate section however, where the images from the BNRImageStore are written using binary mode.

Can someone please explain the reasons for this? Why we did not archive images also for example? etc.
Thank you in advance.


#2

I wondered the same thing, so I tried archiving the UIImage object. I think the reason is file size - if you archive the UIImage object, it takes up a lot more space than the same image saved in JPEG or PNG format (I’m guessing the archived UIImage stores the decompressed data).

EDIT: Since reading on into chapter 15, it seems that UIImage did not conform to NSCoding prior to iOS 5.1, and I guess the 3rd edition predates that so that is most likely the reason, although the original point remains that archiving a UIImage object seems to take up a lot more space than a JPEG or PNG representation of it.