title: MAX / MIN function in Objective C that avoid casting issues
body: <p>I had code in my app that looks like the following.  I got some feedback around a bug, when to my horror, I put a debugger on it and found that the MAX between -5 and 0 is -5!   </p>
  
  <pre><code>NSString *test = @"short";
  int calFailed = MAX(test.length - 10, 0);                      // returns -5
  </code></pre>
  
  <p>After looking at the MAX macro, I see that it requires both parameters to be of the same type.  In my case, "test.length" is an unsigned int and 0 is a signed int.  So a simple cast (for either parameter) fixes the problem.</p>
  
  <pre><code>NSString *test = @"short";
  int calExpected = MAX((int)test.length - 10, 0);                    // returns 0
  </code></pre>
  
  <p>This seems like a nasty and unexpected side effect of this macro.  Is there another built-in method to iOS for performing MIN/MAX where the compiler would have warned about mismatching types?  Seems like this <em>SHOULD</em> have been a compile time issue and not something that required a debugger to figure out.  I can always write my own, but wanted to see if anybody else had similar issues.</p>