 <p>You are missing the <code>else</code> part, thus all three <code>if</code> statements are being evaluated consecutively. If <code>delta == 0</code>, it will satisfy all three <code>if</code> statements. Thus, the last allocation will overwrite the previous two. (And you'll be leaking memory)</p> <p>Also, your <code>message</code> variable is scoped as local to the <code>if</code> block it's declared into. You might want to move the <code>message</code> declaration at the function level scope.</p> <p>As far as <code>%</code> not working, you are using the instance initializer <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/uid/20000154-initWithFormat_locale_arguments_" rel="nofollow noreferrer"><code>initWithFormat</code></a> with the syntax for the class initializer <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/clm/NSString/stringWithFormat:" rel="nofollow noreferrer"><code>stringWithFormat</code></a>. <code>initWithFormat</code> takes the parameters for the formatted string in a separate parameter - <code>arguments:</code>. (Btw, it also requires <code>locale:</code>)</p>