tags:

views:

124

answers:

2

Hi, i am using rss feed.first time ,table view has no rows.if i press button, there will come values.if i press again ,the table view has previous values.after recieving data it disappears and new data will come there.but when i press button ,there cannot be previous value.i want to
remove it.How can i do it? any help?

A: 

When you need to update the contents of your UITableView call [tableView reloadData] method. So if by that time you've cleared your previous data from your data source then the table must get empty.

Vladimir
No. i tried it.suppose if the table has value from one url.if clickthe BUTTON ,it will communicate same url,at that time there is no update,previoue values are there....
Mikhail Naimy
It's hard to say without seeing your code... If previous values still are in the table it must mean that you have not cleared your data source
Vladimir
A: 

The UITableView works by a datasource. I'm going to assume that you have followed Apple's way of setting up a tableview which should look something like this:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{   
    static NSString *identifier = @"identifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

    if (cell == nil) {
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
    }

    cell.textLabel.text = [_tableViewData objectAtIndex:[indexPath row]];

    return cell;
}

In this example the data for the UITableView is stored in the tableViewData array. Which is initialized like:

_tableViewData = [[NSArray arrayWithObjects:@"cell 1", @"cell 2", @"cell 3", @"cell 4", nil] retain];

So when you want to update the values of the tableview to something new you need to change the value of the tableViewData array and call reloadData on the table view.

_tableViewData = [[NSArray arrayWithObjects:@"new cell 1" , @"new cell 2", @"new cell 3", @"new cell 4", nil] retain];
[_tableView reloadData];
klaaspieter