title: Refresh tableView when app becomes active
body: <p>I know there have been a couple questions asked similar to this, but I think my issues is a little different, so bear with me.</p>
  
  <p>I have a tabbed view app with table views set in 2 of the 3 tabs. I want to be able to refresh just the table view of the selected tab when the app wakes back up. I have tried using the notification center to tell my tab to refresh, but it makes the other tab crash because it is stealing the view from my progress hud. I will put some code here, so hopefully I can find a solution that will work for me.</p>
  
  <p>Tab 1 ViewController</p>
  
  <pre><code>- (void)viewDidLoad {
  
      // becomeActive just calls viewDidAppear:
      [[NSNotificationCenter defaultCenter] addObserver:self
                                               selector:@selector(becomeActive:)
                                                   name:UIApplicationDidBecomeActiveNotification
                                                 object:nil];
  
      [super viewDidLoad];
  
  }
  
  -(void)viewDidAppear:(BOOL)animated {
      HUD = [[MBProgressHUD alloc] initWithView:self.view];
      [self.view addSubview:HUD];
  
      HUD.delegate = self;
      HUD.labelText = @"Updating";
      HUD.detailsLabelText = @"Please Wait";
  
      [HUD showWhileExecuting:@selector(refreshData) onTarget:self withObject:nil animated:YES];
  
  }
  </code></pre>
  
  <p>Tab 2 ViewController</p>
  
  <pre><code>- (void)viewDidLoad
  {
  
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      self.navigationItem.title = [defaults valueForKey:@"companyName"];
  
      self.view.backgroundColor = background;
  
      tableView.backgroundColor = [UIColor clearColor];
      tableView.opaque = YES;
      tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  
      // becomeActive just calls viewDidAppear
      [[NSNotificationCenter defaultCenter] addObserver:self
                                               selector:@selector(becomeActive:)
                                                   name:UIApplicationDidBecomeActiveNotification
                                                 object:nil];
  
  
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  
      if (_refreshHeaderView == nil) {
  
          EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.view.frame.size.width, self.tableView.bounds.size.height)];
          view.delegate = self;
          [self.tableView addSubview:view];
          _refreshHeaderView = view;
          [view release];
  
      }
  
      //  update the last update date
      [_refreshHeaderView refreshLastUpdatedDate];
  
  }
  
  -(void)viewDidAppear:(BOOL)animated {
      HUD = [[MBProgressHUD alloc] initWithView:self.view];
      [self.view addSubview:HUD];
      HUD.delegate = self;
      HUD.labelText = @"Updating";
      HUD.detailsLabelText = @"Please Wait";
  
      [HUD showWhileExecuting:@selector(updateBoard) onTarget:self withObject:nil animated:YES];
  
      //  update the last update date
      [_refreshHeaderView refreshLastUpdatedDate];
  
  }
  </code></pre>
  
  <p>With this setup, my application will refresh tab 2 just fine, assuming that tab 2 was the last tab open before you closed the application. If I switch to tab 1 when I close, upon restarting the app, the notification calls tab 2 first and steals the view out from under my progress hud, so when I try to call the viewDidAppear method, the view is null and the app crashes. I either need to figure out how to implement the notification center better so it doesn't crash the other tab, or a better way overall to just refresh when the app becomes active. Looking forward to a good answer. Thanks in advance.</p>
  
  <p><strong>EDIT</strong>
  When I run with this setup, it aborts inside the MBProgressHUD</p>
  
  <pre><code>- (id)initWithView:(UIView *)view {
      // Let's check if the view is nil (this is a common error when using the windw initializer above)
      if (!view) {
          [NSException raise:@"MBProgressHUDViewIsNillException" 
                      format:@"The view used in the MBProgressHUD initializer is nil."]; // &lt;-- Aborts on this line, so they know it can happen
      }
      id me = [self initWithFrame:view.bounds];
      // We need to take care of rotation ourselfs if we're adding the HUD to a window
      if ([view isKindOfClass:[UIWindow class]]) {
          [self setTransformForCurrentOrientation:NO];
      }
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) 
                                                   name:UIDeviceOrientationDidChangeNotification object:nil];
  
      return me;
  }
  </code></pre>