TijuanaKez
TijuanaKez

Reputation: 1472

Accessing properties of a custom UITableView cell

I have a property, specifically a UIActivityIndicatorView in a (reusable) subclass of UITableViewCell. When a cell is selected, an AVAsset is fetched from a URL but I want the UIActivityIndicatorView to hide when the sufficient data has been fetched from the URL and the AVAsset is ready to use. But I don't know how to access the cell that was selected. I figured the best way was to set up a pointer to the last selected cell in a property and access it later like this.

@interface
@property (nonatomic, retain) customTableViewCustomCell *activeCell;
@end

@implementation
@synthesize activeCell;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // remember pointer to active cell for later
    activeCell = [tableView cellForRowAtIndexPath:indexPath];
}

- (void) updateInterface
{
    [activeCell.activityIndicator stopAnimating];
}

But I get a compile error about incompatible pointer types because cellForRowAtIndexPath:indexPath returns a UITableViewCell and not a customUITableViewCell. I need a pointer to customUITableViewCell so I have access to the activtyIndicator IBOutlet property.

Upvotes: 1

Views: 1223

Answers (1)

Shubhank
Shubhank

Reputation: 21805

try this

  activeCell = (customTableViewCustomCell *) [tableView cellForRowAtIndexPath:indexPath];

Upvotes: 1

Related Questions