title: Using a for loop for a UIPickerView
body: <p>I am new here and I am getting my hands dirty on some iPhone applications on XCODE. I am currently creating an app but I am stuck on a particular part that involves a pickerview. Here's the code.</p>
  
  <pre><code>        - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
              if ([pickerView tag] == 0){
                  return [firstColumn count];
              }
              else if ([pickerView tag] == 1){
                  return [OnFirstMin count];
                  return [OnSecMin count];
                  return [OnSecSec count];
                  return [OnFirstSec count];
              }
              else {
                  return [OffFirstMin count];
                  return [OffSecMin count];
                  return [OffFirstSec count];
                  return [OffSecSec count];
              }
  
              return 0;
          }
  
          -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
              if([pickerView tag] == 0){
                  if(component == FIRST){
                      return [firstColumn objectAtIndex:row];
                  }
              }
              else if ([pickerView tag] == 1){
                  if(component == ON1){
                      return [OnSecMin objectAtIndex:row];
                  }
                  else if (component == ON2){
                      return [OnFirstMin objectAtIndex:row];
              }
                  else if (component == ON3){
                      return [OnSecSec objectAtIndex:row];
                  }
                  else {
                      return [OnFirstSec objectAtIndex:row];
                  }
              }
              else {
                  if(component == OFF1){
                      return [OffSecMin objectAtIndex:row];
                  }
                  else if (component == OFF2){
                      return [OffFirstSec objectAtIndex:row];
                  }
                  else if (component == OFF3){
                      return [OffSecSec objectAtIndex:row];
                  }
                  else {
                      return [OffFirstSec objectAtIndex:row];
                  }
              }
  
              return 0;
  
      -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
          if ([pickerView tag] == 0){
              if(sets == TRUE &amp;&amp; reps != TRUE){
                  numofsets = row;
                  SetsTextField.text = [firstColumn objectAtIndex:row];
              }
              else{
                  numofreps = row;
                  RepsTextField.text = [firstColumn objectAtIndex:row];
              }
          }
          else if ([pickerView tag] == 1){
              if(component == ON1){
                  onsecmin = row;
              }
              else if (component == ON2){
                  onfirstmin = row;
              }
              else if (component == ON3){
                  onsecsec = row;
              }
              else {
                  onfirstsec = row;
              }
          }
          else {
              if (component == OFF1){
                  offsecmin = row;
              }
              else if (component == OFF2){
                  offfirstmin = row;
              }
              else if (component == OFF3){
                  offsecsec = row;
              }
              else {
                  offfirstsec = row;
              }
          }
      }
  
    - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      firstColumn = [[NSMutableArray alloc] init];
      for(i=0; i&lt;=30; i++){
          [firstColumn addObject: [NSString stringWithFormat:@"%d", i]];
      }
  
      OnSecMin = [[NSMutableArray alloc] init];
      OnFirstMin = [[NSMutableArray alloc] init];
      for(j=0; j&lt;60; j++){
          [OnSecMin addObject:[NSString stringWithFormat:@"%i", j]];
          [OnFirstMin addObject: [NSString stringWithFormat:@"%i", j]];
      }
  
  
      OnSecSec = [[NSMutableArray alloc] init]; //Part where I need help. 
      k =0;
      while (k&lt;60){
      [OnSecSec addObject: [NSString stringWithFormat:@"%i",k]];
      k = k+15;
      }
  
  
      PickerViewSetsRepsContainer.frame = CGRectMake(0, 600, 320, 206);
      PickerViewOnContainer.frame = CGRectMake(0, 610, 320, 206);
      PickerViewOffContainer.frame = CGRectMake(0, 620, 320, 206);
  
  
  }
  </code></pre>
  
  <p>So, for OnSecSec, I want the rows to display 0, 15, 30, and 45 for that component. However, when I run it, the application is aborted. However, when I change that part to a for loop like I did for OnSecMin and OnFirstMin, it works. How come I can't use a while loop like above? Also, can someone help me with this dilemma? Thank you very much for your assistance in advance! </p>