Enable -Wformat for better compile time help
Apr 18, 2009 · 1 minute readosxxcodetipsiphone
Let the compiler do all the hard work, and be sure to enable the following warning:
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: