Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The code looks more or less right to me, aside from the memory leak. You should review <a href="http://developer.apple.com/mac/library/documentation/General/Conceptual/DevPedia-CocoaCore/MemoryManagement.html" rel="nofollow noreferrer">the memory management rules</a> and fix your leak.</p> <p>My guess is that the numbers you entered add up to a number that is outside the range of an <code>int</code>. Entering, say, 1000000000 (10**9) in each of the five fields would be one way to pull this off, on any machine where an <code>int</code> is 32 bits (including, currently, the iPhone-OS devices).</p> <p>Depending on the purpose of your app, you may be able to simply cap the five input fields; if the highest value that makes any sense is less than one-fifth (for five fields, and that's assuming they all have the same cap) of the maximum <code>int</code>, overflow is impossible.</p> <p>If a cap won't solve the problem completely, try a different type. If the values should never be negative, use an unsigned type. Otherwise, try <code>long long</code>, or either of the floating-point types, or use NSDecimalNumber objects.</p> <p>Of course, I could be completely wrong, since you didn't say what numbers you entered or what the result was. If it was zero, make sure that you hooked up your outlets in IB; if you forgot to do that, they contain <code>nil</code>, which, when you ask it for <code>text</code>, will return <code>nil</code>, which, when you ask it for an <code>intValue</code>, will return 0, and 0 + 0 + 0 + 0 + 0 = 0.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload