title: How to get NSTimer to loop
body: <p>I'm trying to learn about <code>NSTimer</code>, using Foundation and printing to the console. Can anybody tell me what I need to do to get the following to work? It compiles with no errors, but does not activate my <code>startTimer</code> method -- nothing  prints.</p>
  
  <p>My aim is to get one method to call another method to run some statements, and then stop after a set time.</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface MyTime : NSObject {
      NSTimer *timer;
  }
  - (void)startTimer;
  @end
  
  @implementation MyTime
  
  - (void)dealloc {
      [timer invalidate];
      [super dealloc];
  }
  
  - (void)startTimer {
       timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(runTimer:) userInfo:nil repeats:YES];
  }
  
  - (void)runTimer:(NSTimer *)aTimer {
      NSLog(@"timer fired");
  }
  @end
  
  
  int main(int argc, char *argv[]) {
      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  
  
      MyTime *timerTest = [[MyTime alloc] init];
      [timerTest startTimer];
  
      [timerTest release];
  
      [pool release];
      return 0;
  }
  </code></pre>