title: How to limit character input in UIAlertView UITextField
body: <p>I am trying to limit the number of characters my user is allowed to input into my <code>UITextField</code> within my <code>UIAlertView</code>.</p>
  
  <p>I've tried the some common answers on the web. Such as shown below :</p>
  
  <pre><code>  #define MAXLENGTH 10
  
  
  - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
      if ([textField.text length] &gt; MAXLENGTH) {
          textField.text = [textField.text substringToIndex:MAXLENGTH-1];
          return NO;
      }
      return YES;
  }
  </code></pre>
  
  <p>Anyone able to help?</p>