title: How do I add a UIActivity Indicator to every Cell and maintain control of each individual indicator
body: <p>I'm trying to add an activity indicator to certain cells in my UITableView. I do this successfully in the method didSelectRowAtIndexpath using</p>
  
  <pre><code>    CGRect CellFrame = CGRectMake(260, 10, 20, 20);
      actindicator = [[UIActivityIndicatorView alloc]initWithFrame:CellFrame];
      [actindicator setHidesWhenStopped:NO];
      [actindicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
      actindicator.tag =1;
      [[cell contentView] addSubview:actindicator];
  </code></pre>
  
  <p>The catch is I need to control these multiple activity indicators from ANOTHER METHOD. I figured a property was a way to do this however by initialising a new instance of actIndicator every time, I loose reference's to all but the 'latest' init of the activity indicator thus meaning I can only control one.</p>
  
  <p>What do i need to do here (if even possible?) to maintain reference to all the actIndicators so i can begin animating ALL of them?
  Or Can I somehow use the actindicator.tag to control some form of reference.</p>
  
  <p>Many thanks for any help.</p>
  
  <p><strong>EDIT:</strong> (Derived from answer) to access all Instances of Activity indicator with a tag of 1 in tableView (visible cells only) can use below from another method:</p>
  
  <pre><code>for (UITableViewCell *cell in [self.tableView visibleCells]) {
      UIActivityIndicatorView *actView = (UIActivityIndicatorView *)[cell.contentView
      viewWithTag:1];
      [actView startAnimating];
      activityFlag = 1;
  
  }
  </code></pre>
  
  <p>The method above will cycle through all visible cells and start animating the activity indicator.</p>
  
  <p>To handle the case of the tableview being scrolled, I re-animate the indicators using the method below which is in cellForRowAtIndexPath. cellStateKey simply indicates if the cell has a checkmark next to it, if it does have a checkmark and my activityflag (async webserver call in progress)is set..then i want to continue animating.(technically re-start animation, as scrolling tableview stops it)</p>
  
  <pre><code>if ([[rowData objectForKey:cellStateKey] boolValue]) {
  
      cell.accessoryType = UITableViewCellAccessoryCheckmark;
  
        if(cell.accessoryType == UITableViewCellAccessoryCheckmark &amp;&amp;activityFlag ==1){
  
          for (UIView *sub in [[cell contentView] subviews]) {
  
              if (sub.tag == 1) {
  
                  UIActivityIndicatorView *acView = (UIActivityIndicatorView *)
                  [cell.contentView viewWithTag:1];
                  [acView startAnimating];
  
  
              }
  
          }
  </code></pre>
  
  <p>As mentioned in origional question I initialise my activity indicators (and remove activity indicators aswell if required) in the method didSelectRowAtIndexPath</p>