0
votes

I have a UITableView that is put onto a view based app. it is wired up properly because I can initially send it data. The problem is clearing the table. I can clear the NSMutableArray but the data still shows up in the table.

-(void)logout {
NSLog(@"LOGOUT");

[friends removeAllObjects];
NSLog(@"%@", friends);
[tableView reloadData];
}

and here is the cell for row at index path: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {

    cell = [[UITableViewCell alloc] initWithFrame:CGRectZero];
}

// Set up the cell...
NSString *cellValue = [friends objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;


return cell;
}
1
Whats your method that returns the number of rows in a tableview look like? - Daniel
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [friends count]; } - Michael Amici

1 Answers

0
votes

Create a dedicated reference

@property(nonatomic, retain) IBOutlet UITableView *tableViewReference;

Reload that reference in the logout method.