title: textField:shouldChangeCharactersInRange:replacementString:
body: <p>How can I correct this code. I want only numbers and range should be not exceed to 10.
  My code is</p>
  
  <pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
      NSUInteger newLength = [textField.text length] + [string length] - range.length;
      return (newLength &gt; 10) ? NO : YES;
  
      static NSCharacterSet *charSet = nil;
      if(!charSet) {
          charSet = [[[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet] retain];
      }
      NSRange location = [string rangeOfCharacterFromSet:charSet];
      return (location.location == NSNotFound);
  }
  </code></pre>