title: NSTimer and updating UI
body: <p>Ive been trying to get my game to work correctly with an <code>NSTimer</code>. Ive seen many people have had a similar problem to me and I just need a bit of clarification on something. </p>
  
  <p>Basically I have an <code>NSTimer</code> running on the main thread which is updating images which represent the time, but I also have a mapView. When the user pans the map the timer is blocked. My question is if I create a new thread and add the timer to its runloop, when I perform selector (which updates UI) will this not block the timer thread again? Also I know it is bad practise to update the UI from secondary thread so how would I go about that?</p>
  
  <p><strong>UPDATE:</strong> I think the mapView was blocking the timer as they were both running in the same run loop. I have now fixed this with a timer thread with its own run loop, however this has led me to a 2nd problem which has me extremely stuck!! Here is the code...</p>
  
  <pre><code>//called when I need to restart the timer
  [NSThread detachNewThreadSelector:@selector(resumeTimer) toTarget:self withObject:nil];  
  
  
  -(void) restartTimer {
  
      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
      timer=[NSTimerscheduledTimerWithTimeInterval:1.
                                            target:self
                                          selector:@selector(dim)
                                          userInfo:nil
                                           repeats:YES];
  
      [self performSelectorOnMainThread:@selector(timerImageUpdate)
                             withObject:nil
                          waitUntilDone:NO];
  
      [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
      [[NSRunLoop currentRunLoop] run];
  
      [pool drain];
  }
  </code></pre>
  
  <p>This code gives me a <em>Bad_access error on the [pool drain]</em>;</p>
  
  <p>I have run the code in instruments and still cannot see why it gives me the error. Any ideas?</p>