title: Need help with an activity indicator
body: <p>I can't get my activity indicator to work.</p>
  
  <p>Here's what I've got-</p>
  
  <pre><code>-(void)viewWillAppear:(BOOL)animated{
  [super viewWillAppear:YES];
  //Create an instance of activity indicator view
  UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
  //set the initial property
  [activityIndicator stopAnimating];
  [activityIndicator hidesWhenStopped];
  //Create an instance of Bar button item with custome view which is of activity indicator
  UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
  //Set the bar button the navigation bar
  [self navigationItem].rightBarButtonItem = barButton;
  //Memory clean up
  [activityIndicator release];
  [barButton release];
  }
  </code></pre>
  
  <p>The part of the code that is supposed to get it started and then ended--</p>
  
  <pre><code>...
      else if ([theSelection isEqualToString: @"Update statistics"])
      {
          [self startTheAnimation];
          [updateStatistics  updateThe2010Statistics];
          [self stopTheAnimation];
      }
  ...
  
  
  -(void)startTheAnimation {
      [(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView startAnimating];
  }
  
  -(void)stopTheAnimation {
      [(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView stopAnimating];
  }
  </code></pre>