tags:

views:

97

answers:

1

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.?

+1  A: 

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.

Henrik P. Hessel
I tried that already..its not working
Akki
did the datasource actually changed? did you try (most of the time) tableView.datasource = self;
Henrik P. Hessel
I can't see that datasource being actually changed...as on recalling its not going in numberofRowindex method
Akki
so if the datesource is not changed how should the table be updated (changed)?
Henrik P. Hessel
so I am doing anything wrong? as you can see from my code I used singleton class to access my shared variable,( and i know variable is updated) in numberofRowIndex method, but its not going on to that method when I am recalling my view containing table
Akki
Any Answers??????
Akki
Yes, you're doing something wrong. I've given you a correct answer. The problem lies somewhere else in your code.
Henrik P. Hessel
Could you please guide me..how I should approach in this matter? You can see from my code what I am trying to do.
Akki
Sorry, but I have to say: Before u read the mentioned documentation, u should study basic C and Objective-C. There are several errors in ur Code: x is neither allocated nor initialized — only the name "x" exits. u cannot to anything after a return in a method.
vikingosegundo
I dun need x that's why I dun care what it has to do after a return in a method
Akki
releasing is important. u are not releasing, as [... release] will never be called, ur code is wrong and u are missing important things about the programming language u r using. take my advice, study objc from the beginning. If u present code like that on SO, u barely can't expect help, because nobody will be able to tell where to start http://www.osnews.com/story/19266/WTFs_m
vikingosegundo