Mamas, don’t let your babies grow up to put important code in the dealloc method

Here is something you may not have noticed (yet). If you use the ZipArchive code to create zip files in your iOS app, and you convert your app code to ARC, your zip files might not be created correctly. The problem exists here in the ZipArchive.mm file:

-(void) dealloc
{
	[self CloseZipFile2];
	[super dealloc];
}

If you use the CreateZipFile2 method to create your zip file, previously you would call the release method on your ZipArchive object, and the memory would be flushed away. Unbeknownst to you (but beknownst to the ZipArchive devs), your zip file was A-OK because of the CloseZipFile2 method call in the dealloc method.

But ARC conversion removes the release messages! Bugger!!! Just manually put in a call to CloseZipFile2 everywhere that you use the CreateZipFile2 method.

BTW, Happy Birthday to Kent Tekulve, former Pirates great and commissioner of the Pittsburgh Pirates Fantasy Camp. Unfortunately Teke could not make it to camp due to illness this year, we missed you Teke and hope you are feeling better.

Leave a Reply