title: Adding object to NSMutableArray or Converting Float to NSNumber
body: <p>Having difficulties apparently with either adding elements to a NSMutableArray or to converting float to a NSNumber. </p>
  
  <p>Here is a working <code>while</code> loop that uses simple C arrays and not NSMutableArray. It was tested with <code>printf's</code>: </p>
  
  <pre><code>    #define MAXSIZE 50
  
      float xCoordinate [MAXSIZE] = {0.0};
      float yCoordinate [MAXSIZE] = {0.0};
  
      float x;
      float y;
  
      // ... some code creating handle from a .txt file
  
          while ((fscanf(handle, " (%f;%f)", &amp;x, &amp;y)) == 2)
          {
              printf("%f\n",x);
              printf("%f\n",y);
  
              xCoordinate[n] = x;
              yCoordinate[n] = y;
  
              printf("Here is value from the array %f\n", xCoordinate[n]);
              printf("Here is value from the array %f\n", yCoordinate[n] );
              n++;
              if ( n &gt;= MAXSIZE)
              {
                  break;
              }
          }
  </code></pre>
  
  <p>The  reason I want to switch to the NSMutable array is because I want count number of elements in the xCoordinate or yCoordinate arrays. 
  I think it is easier to just send the function <code>count</code> to an array. </p>
  
  <p>Here are loops that didn't work for me and the don't assign values from scanf to x and y. </p>
  
  <p>Using <code>while</code>loop: </p>
  
  <pre><code>    NSMutableArray *xCoordinate;
      NSMutableArray *yCoordinate;
      float x;
      float y;
      int n =0;
  
      while ( ( fscanf(handle, " (%f;%f)", &amp;x, &amp;y) ) == 2)
          {    
              // these 2 lines don't work as suppose to. What's wrong?        
              [xCoordinate addObject:[NSNumber numberWithFloat:x]];
              [yCoordinate addObject:[NSNumber numberWithFloat:y]];
  
  
              printf("asdf %f\n", [[xCoordinate objectAtIndex:n] floatValue]);
              printf("asdf %f\n", [[yCoordinate objectAtIndex:n] floatValue]);
  
  
  
              n++;
              if ( n &gt;= MAXSIZE)
              {
                  break;
              }
          }
  </code></pre>
  
  <p>using <code>for</code> loop:</p>
  
  <pre><code>    NSMutableArray *xCoordinate;
      NSMutableArray *yCoordinate;
      float x;
      float y;   
  
      for  (n=0; ((fscanf(handle, " (%f;%f)", &amp;x, &amp;y)) == 2); n++)
          {
              // these 2 lines don't work as suppose to. What's wrong?        
              [xCoordinate addObject:[NSNumber numberWithFloat:x]];
              [yCoordinate addObject:[NSNumber numberWithFloat:y]];
  
  
              printf("asdf %f\n", [[xCoordinate objectAtIndex:n] floatValue]);
              printf("asdf %f\n", [[yCoordinate objectAtIndex:n] floatValue]);
  
              if ( n &gt;= MAXSIZE)
              {
                  break;
              }
          }
  </code></pre>