How do I read image files directly from a zip without extracting to disk?

cocoa, macos, objective-c

Solution

Use objective-c zip (iOS/Mac zlib wrapper)

Then you can do:

ZipFile *unzipFile= [[ZipFile alloc] initWithFileName:@"test.zip" mode:ZipFileModeUnzip];
[unzipFile goToFirstFileInZip];

ZipReadStream *read= [unzipFile readCurrentFileInZip];
NSMutableData *data= [[NSMutableData alloc] initWithLength:256];
int bytesRead= [read readDataWithBuffer:data];

[read finishedReading];

Problem

What I want to do is assign images to ui elements at runtime (think Winamp style) but I have no idea how to go about reading from a zip without storing to disk. Or how to assign each image to a ui element I'm working on a mac with cocoa and objective c

Original source

Related problems