tags:

views:

13

answers:

0

Hi,

I'm dynamically inserting rows into a tableview. When I try to scroll in the simulator, it crashes with bad access memory. Any ideas?

I populate the tableview after getting a notification that another event has occurred.

-(void)populateTableView:(NSNotification *)notification{
NSMutableArray *eventArr = eventData.getEventListing;
NSMutableArray *tempArray = [[NSMutableArray alloc] init];

int i = 0;
for (NSArray *count in eventArr) {
    [tempArray addObject:[NSIndexPath indexPathForRow:i++ inSection:0]];
}

[[self tableView] beginUpdates];
[[self tableView] insertRowsAtIndexPaths:(NSArray *)tempArray withRowAnimation:UITableViewRowAnimationNone];
[[self tableView] endUpdates];

[tempArray release]; 
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellular"];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellular"] autorelease];
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
 } 

NSDictionary *aDict = (NSDictionary *)[self.eventData.eventListing objectAtIndex:indexPath.row];

cell.text = [aDict objectForKey:@"name"];

return cell;
 }