title: Determine if the first character of a string is 1 or not
body: <p>Basically I'm working on something that looks like the phone apps keypad. Everything else is inputting as it should but what I'm trying to figure out is how on this last one to get it when a 1 is inputted first that the number would look like 1 (555) 555-5555. I'm sure my code will need some tweaking to the substringfromindexes to get it to match up, but what I'm trying to get to happen now is just to check if the entered strings first number is a one or not. Because if it is not it will just bypass this part of code.</p>
  
  <pre><code>else if ([self.self.enteredPhoneNumberString length] == 11 &amp;&amp; [self.enteredPhoneNumberString characterAtIndex:0] == '1') {
          NSString *firstNum = [self.enteredPhoneNumberString substringToIndex:1];
          NSString *createFirst = [self.enteredPhoneNumberString substringFromIndex:3];
          NSString *firstThree = [createFirst substringToIndex:3];
          NSString *createSecond = [self.enteredPhoneNumberString substringFromIndex:3];
          NSString *secondThree = [createSecond substringToIndex:3];
          NSString *lastSet = [self.enteredPhoneNumberString substringFromIndex:6];
          self.label.text = [NSString stringWithFormat:@"%@ (%@) %@-%@", firstNum, firstThree, secondThree, lastSet];
      }
  </code></pre>
  
  <p>If you know of the way to adjust the substrinFromIndex to get the effect I'm going for too by all means that would save me time tampering until I find the right order. Thanks in advance for all help. :)</p>
  
  <p>Oh and btw with the above code it did a breakpoint when I got to the this part in the code.</p>
  
  <p>FIX:</p>
  
  <p>Thanks for all the help it works now. Ended up doing this and for some reason the breakpoint doesnt happen when it is done here.</p>
  
  <pre><code>else if ([self.self.enteredPhoneNumberString length] &gt;= 11 ) {
      if ([self.enteredPhoneNumberString characterAtIndex:0] == '1' &amp;&amp; [self.self.enteredPhoneNumberString length] == 11) {
          NSString *firstNum = [self.enteredPhoneNumberString substringToIndex:1];
          NSString *createFirst = [self.enteredPhoneNumberString substringFromIndex:1];
          NSString *firstThree = [createFirst substringToIndex:3];
          NSString *createSecond = [self.enteredPhoneNumberString substringFromIndex:4];
          NSString *secondThree = [createSecond substringToIndex:3];
          NSString *lastSet = [self.enteredPhoneNumberString substringFromIndex:7];
          self.label.text = [NSString stringWithFormat:@"%@ (%@) %@-%@", firstNum, firstThree, secondThree, lastSet];
      }
      else{
         self.label.text = [NSString stringWithFormat:@"%@", enteredPhoneNumberString]; 
      }
  }
  </code></pre>
  
  <p>And ya it does seem pointless to have to check if the length is 11 again, but because it was causing issues the previous way I didnt really have much of a choice because I needed it to know whether it exceeded 11 or not so it could start doing that else.</p>