title: EXC_BAD_ACCESS at [self.tableView reloadData]
body: <p>I'm making a simple app that makes some calculations. Some of these calculations are rather complex, so it may take a while to get the result. I'm using <code>UITableView</code> to let user input the values. Then after clicking the "Calculate" button I make a simple <code>UIView</code> with an <code>UIActivityIndicatorView</code> on it and I put it in the middle of the screen. And then I call the calculating method in the background. Some code:</p>
  
  <pre><code>    self.activityIndicatorView = [[UIView alloc]initWithFrame:CGRectMake(320/2 - 50, (480 - 64)/2 - 50, 100, 100)];
      self.activityIndicatorView.layer.cornerRadius = 10.0f;
      self.activityIndicatorView.backgroundColor = [UIColor colorWithRed:0. green:0. blue:0. alpha:0.7];
      UIActivityIndicatorView *actInd = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
      actInd.frame = CGRectMake((100 - actInd.frame.size.width) / 2, (100 - actInd.frame.size.height) / 2, actInd.frame.size.width, actInd.frame.size.height);
      [actInd startAnimating];
      [self.activityIndicatorView addSubview:actInd];
      [self.activityIndicatorView bringSubviewToFront:actInd];
      [self.view addSubview:self.activityIndicatorView];
      [self.view bringSubviewToFront:self.activityIndicatorView];
      [self performSelectorInBackground:@selector(calculateAllThatShizzle) withObject:nil];
  </code></pre>
  
  <p>As you see, it is pretty simple. But if the keyboard is still visible it crashes(<code>EXC_BAD_ACCESS</code>) when it gets to <code>[self.tableView reloadData]</code> in the <code>-(void)calculateAllThatShizzle</code> method with that in the log:</p>
  
  <pre><code>2012-03-23 11:06:32.418 MyApp[869:5c07] bool _WebTryThreadLock(bool), 0x6adb270: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
  1   WebThreadLock
  2   -[UITextRangeImpl isEmpty]
  3   -[UITextRange(UITextSelectionAdditions) _isCaret]
  4   -[UITextSelectionView setCaretBlinks:]
  5   -[UIKeyboardImpl setCaretBlinks:]
  6   -[UIKeyboardImpl setDelegate:force:]
  7   -[UIKeyboardImpl setDelegate:]
  8   -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
  9   -[UIResponder _finishResignFirstResponder]
  10  -[UIResponder resignFirstResponder]
  11  -[UITextField resignFirstResponder]
  12  -[UITableView reloadData]
  13  -[ChildViewController calculateAllThatShizzle]
  14  -[NSThread main]
  15  __NSThread__main__
  16  _pthread_start
  17  thread_start
  </code></pre>
  
  <p>So the problem is that it is trying to do something with the keyboard from a background thread. I've tried looping through the cells and call <code>[cell.rightTextField resignFirstResponder]</code>, but it doesn't help. I also tried using that</p>
  
  <pre><code>-(void)reloadTableViewData {
    [self.tableView reloadData];
  }
  -(void)calculateAllThatShizzle {
    //some code omitted - code that uses UIKit
    if ([dob timeIntervalSinceDate:calcDate]&gt;0) {
              [errorButton setTitle:@"Calculation Date must be more than Date of Birth" forState:UIControlStateNormal];
              errorButton.hidden = NO;
              [self.activityIndicatorView removeFromSuperview];
              self.activityIndicatorView = nil;
              return;
          }
    [self performSelectorOnMainThread:@selector(reloadTableViewData) withObject:nil waitUntilDone:NO];
  }
  </code></pre>
  
  <p>but it doesn't help either. I'm using <code>ELCTextfieldCell</code></p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thank you</p>
  
  <p>P.S. I did check some other questions about <code>EXC_BAD_ACCESS</code> on reloadData, but it doesn't cover the problem that I have</p>
  
  <p>P.P.S. I can also just run the calculations in the main thread, but then GUI becomes unresponsive and the activity indicator doesn't show up</p>