title: how to pause and stop calculation in iOS
body: <p>I have some calculation that I will show you in codes. I know how to start this calculation but I don't have any idea how to pause and stop during calculation let me write the code so that easy for you to understand.</p>
  
  <p><strong><em>.m file</em></strong> </p>
  
  <pre><code>@interface ViewController (){
  float f;
  }
  @property double result;
  @end
  
   @implementation ViewController
   @synthesize textLabel;
   @synthesize TimeLabel;
  
   -(void)calculatingPIValue{
   NSDate *methodStart = [NSDate date];
      int r[2800 + 1];
      int i,k;
      int b;
      int d;
      double c = 0;
      for ( i = 0; i &lt; 2800; i++) {
  
          r[i] = 20000; }
      for ( k = 2800; k &gt; 2790; k -= 14){
  
          d = 0;
          i = k;
          for (;;) {
              d += r[i] * 10000;
  
              b = 2 * i - 1;
              r[i] = d % b;
              d /= b;
              i--;
              if (i == 0) break;
              d *= i;
          }
          f = ((c + d) / 10000000)/10;
           NSLog(@"the value is %.09f",f);
      }
      self.textLabel.text = [NSString stringWithFormat:@"%.08f",f];
      NSDate *methodFinish = [NSDate date];
      NSTimeInterval executionTime = [methodFinish      timeIntervalSinceDate:methodStart];
      NSLog(@"executionTime = %f", executionTime);
      TimeLabel.text = [NSString stringWithFormat:@"%f",executionTime];
  
      });
  - (IBAction)startButtonPressed:(UIButton *)sender{
  
    [self calculatingPIValue];
  
  
    }
  
  
    - (IBAction)pauseButton:(UIButton *)sender {
    }
  
    - (IBAction)stopButton:(UIButton *)sender {
    }
    @end
  </code></pre>