title: How to count numbers in a string
body: <p>i have a string with string length of 56.</p>
  
  <p>First i tried to make sure, that the string hast the right length, if not, the app should fill several labels with other content.</p>
  
  <pre><code>if ([[NSString stringWithContentsOfURL:siteURL] length] == 56) {
  
      NSString *siteString = @"http://www.xxxx/iphone.txt";   
      NSURL *siteURL  = [NSURL URLWithString:siteString];
      myField2.text = [NSString stringWithContentsOfURL:siteURL encoding:NSUTF8StringEncoding error:nil]; 
      [NSString stringWithContentsOfURL:siteURL encoding:NSUTF8StringEncoding error:nil];
      NSArray *myArray = [[NSString stringWithContentsOfURL:siteURL encoding:NSUTF8StringEncoding error:nil] componentsSeparatedByString: @":  "];
  
  
      [myField2 setText: [myArray objectAtIndex: 0]];
      [myField3 setText: [myArray objectAtIndex: 1]]; 
      [myField4 setText: [myArray objectAtIndex: 2]];
      [myField5 setText: [myArray objectAtIndex: 3]];
      [myField6 setText: [myArray objectAtIndex: 4]];
  
  
  }
  else {
  
      [myField2 setText: @"-"];
      [myField3 setText: @"-"];   
      [myField4 setText: @"-"];
      [myField5 setText: @"-"];
      [myField6 setText: @"-"];
  }
  </code></pre>
  
  <p>In my string there are usually 28 numbers.
  I want my app to check the string, wether there are 28 numbers or not.
  I tried to use the following code:</p>
  
  <pre><code>for (int number = 0; number = 28; number++) {
  </code></pre>
  
  <p>}</p>
  
  <p>But i guess that is not the right way.</p>
  
  <p>I have a given range, 56, and possible numbers 0-9, any ideas how the code has to look like?</p>
  
  <p>Thanks in advance :)</p>
  
  <p>Well i tried it:</p>
  
  <pre><code>for (int number = 0; number &lt; 56; number++){
      unichar c = [[NSString stringWithContentsOfURL:siteURL] characterAtIndex:number];
  
      if (c &gt;= '0'  &amp;&amp;  c &lt;= '9'){
          number++;
  
          if (number = 28) {
              NSString *siteString = @"http://www.xxxx/iphone.txt";   
              NSURL *siteURL  = [NSURL URLWithString:siteString];
              myField2.text = [NSString stringWithContentsOfURL:siteURL encoding:NSUTF8StringEncoding error:nil]; 
              [NSString stringWithContentsOfURL:siteURL encoding:NSUTF8StringEncoding error:nil];
              NSArray *myArray = [[NSString stringWithContentsOfURL:siteURL encoding:NSUTF8StringEncoding error:nil] componentsSeparatedByString: @":  "];
  
  
              [myField2 setText: [myArray objectAtIndex: 0]];
              [myField3 setText: [myArray objectAtIndex: 1]]; 
              [myField4 setText: [myArray objectAtIndex: 2]];
              [myField5 setText: [myArray objectAtIndex: 3]];
              [myField6 setText: [myArray objectAtIndex: 4]];
          }
  
          else {
              [myField2 setText: @"-"];
              [myField3 setText: @"-"];   
              [myField4 setText: @"-"];
              [myField5 setText: @"-"];
              [myField6 setText: @"-"];
  
          }
  
  }
  }
  </code></pre>
  
  <p>But it doesn't work, i guess i made some mistakes :x</p>
  
  <p>current code:</p>
  
  <pre><code>int i = 0; 
  
  for (int numberc = 0; numberc &lt; 56; numberc++){ 
      unichar c = [[NSString stringWithContentsOfURL:siteURL encoding:NSASCIIStringEncoding error:&amp;error] characterAtIndex:numberc]; 
  
      // Funktion die bestimmt, dass bei jedem positiven Match der Zähler um eins erhöht wird.    
      if (c &gt;= '0'  &amp;&amp;  c &lt;= '9'){ //Parameter für das Absuchen des Strings
          i++;
      }
  }
  </code></pre>