user2652032
user2652032

Reputation: 85

add pictures to the project through a zip

I have an application that takes up too much space and I would like to lower the weight, so I had decided to put all the images in a zip file and install it in the application rather than adding the images to the project. Is it possible, or does someone have a better idea? thanks

Upvotes: 0

Views: 60

Answers (2)

Fr4ncis
Fr4ncis

Reputation: 1387

Compressing the images by putting them in a zip, given they're already in a compressed format (.jpg, .gif, .png, etc.), should not yield any appreciable gain in the size of the app, considering the effort to build the mechanism, the time it takes to unzip the files and the space in memory to keep a copy of the ucompressed files.

I would rather suggest compressing properly the images, by reducing the quality or trying with different file formats (like JPG2000).

Upvotes: 5

Nikos M.
Nikos M.

Reputation: 13783

You can use this and unzip the files within your app:

- (void)UnzippingZipFile {

    NSArray  *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *outputPath = [documentsDirectory stringByAppendingPathComponent:@"/FolderName"];

    NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"ZipFile.zip"];
    NSString *zipPath = filePath;

    [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];

}

Upvotes: 0

Related Questions