title: How to add value into array overtime user click on next button in xcode?
body: <p>When the user click the next button, it generate random number and I would like to store the number into the array. My array is storing the last number only. Should I initialize the array outside the 'next' function? Moreover, I would like the 'back button' to read the array from the last in number. Please advise.</p>
  
  <pre><code>- (IBAction)Next:(id)sender {
  
      // Do any additional setup after loading the view from its nib.
  
      //generate random number - result is a range of 0-10   
      int randomnumber = (arc4random() % 10);
  
     // Add the random number into array
     [myArray addObject:[NSNumber numberWithInt:randomnumber]];
  
      // easy way to look what is now in the array
          NSLog([myArray description]);
  
       NSString *fileName = [NSString stringWithFormat:@"File_no_%d", randomnumber +1];
  
      //render a complete file-path out of our filename, the main-bundle and the file-  extension
  
      NSString *filePath=[[NSBundle mainBundle] pathForResource:fileName ofType:@"txt"];
  
      //fetch the text content from that file
  
      NSString *myText= [NSString stringWithContentsOfFile:filePath
                                                  encoding:NSUTF8StringEncoding
                                                     error:nil];
  
      //hand that text over to our textview
  
      TextView.text=myText;
  }
  
  - (IBAction)Back:(id)sender {
  
      NSNumber *last_array_num = [myArray objectAtIndex:myArray.count - 1];
  
     // read the file name based on the last number in array
  
      NSString *fileName = [NSString stringWithFormat:@"File_no_%d", last_array_num ];
  }
  </code></pre>