AKG
AKG

Reputation: 408

How to reload table view with new data

I am calling other view controller name "cityState" on button click which has table in it. code for calling that view on button click(which has table):

[self presentModalViewController:cityState animated:YES];  

now in this view controller I am loading my table with data, its working fine for first time.
For example numberofRowsInSection is like:

-(NSInteger) tableView:(UITableView *)tableView 
 numberOfRowsInSection:(NSInteger)section 
{ 
    SingleTon *s = [SingleTon sharedInstance1]; 
    NSMutableArray *x; 
    rn =[s getRName:x]; 
    NSLog(@"rname : %@",rn); 
    return [rn count];
    [s release];  
    [ss release];  
    [x release];
}

I have a button on this view, and on button press I am going back to the view from which I called this cityStae view

//code for button click 
[self dismissModalViewControllerAnimated:YES]; 

Now I when I am back on the first view, here I am changing the value of rn (as rn I am using in table view) and calling the table view again with same button click as I did first time, view is called and it is showing with old value of rn and I can see at this time of call NSLog in my numberofRowsInSection is not reached. So the old table with old data is displayed.
My question is how to show table with new data.?

Upvotes: 1

Views: 1170

Answers (1)

Henrik P. Hessel
Henrik P. Hessel

Reputation: 36617

You could use [tableView reloadData];

Reference: UITableView Class Reference by Apple

But always make sure that you set the correct delegate and datasource for your UITableView.

Upvotes: 3

Related Questions