title: Remove WhiteSpace from start of uitextfield
body: <p>I want to remove white space from start of word. i.e my first character should not be space and having only one space in between two words .I am trying lots of things but not able to remove space from starting.</p>
  
  <p><strong>My code is:</strong></p>
  
  <p><strong>controller.h</strong></p>
  
  <pre><code>int whitespaceCount;
  </code></pre>
  
  <p><strong>controller.m</strong></p>
  
  <pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  {
      NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
      if ([string rangeOfCharacterFromSet:whitespace].location != NSNotFound)
      {
          whitespaceCount++;
          if (whitespaceCount &gt; 1)
          {
              return NO;
          }
      }
      else
      {
          whitespaceCount = 0;
          return YES;
      }
  }
  </code></pre>
  
  <p>from above code one space between two words are works perfectly. Please suggest me how i remove starting space. Thanks in advance.</p>