How can I tell UITableView to re-render itself when I add some new data? I am executing this code ib loadView method.
[NSThread detachNewThreadSelector:@selector(addSomeData) toTarget:self withObject:nil];
This is addSomeData method:
-(void)addSomeData{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
for (int i = 1; i <= 100; i++) {
[myArray addObject:[NSString stringWithFormat:@"Page %i",i]];
NSDate *d2 = [NSDate dateWithTimeIntervalSinceNow:0.2f];
[NSThread sleepUntilDate:d2];
}
[pool release];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSString *string = [myArray objectAtIndex:indexPath.row];
cell.textLabel.text = string;
// Configure the cell...
return cell;
}
myArray ist is NSArray which contains string. SO the main question is - how to dynamically update tableview when I add new NSString to myArray?