Saturday, April 18, 2009

Enable -Wformat for better compile time help

Let the compiler do all the hard work, and be sure to enable the following warning:

Picture 1.png

It does more than just validate printf/scanf formatting calls, which is helpful in itself. It also validates that a sentinel is present in variadic functions. A sentinel is typically NULL or nil for the last parameter. A common place you would benefit from this is using the arrayWithObjects method of NSArray, that requires a nil for the last value.

NSArray *items = [NSArray arrayWithObjects:@"one", @"two", nil];

If the nil is absent, you're receive the following:

Picture 3.png

Friday, April 03, 2009

Small Zip / Unzip library for iPhone

I have looked with ZipArchive, which is an Objective-C compression framework; however, I ended up using Lite Zip / Unzip on codeproject as it is just two .C files. Include one for compressing ZIP files and the other for decompressing.