How can I reload data in tableview in view controller in iphone
I am new to iphone development. I have created 5 buttons in the view. On clicking the buttons it navigates to the corresponding views. On clicking the "News" button it navigates and displayed the parsing details in the table view.(This table view, I have created View controller and added table view using Interface Builder and I have set all the properties.) and I go to another button and comes back to the "News" button, every time parsing will happened.How to avoid the multiple parsing开发者_StackOverflow社区 when I come back to the button.
I have tried this one and my code is,
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
static int i;
if(i == 0)
{
NSString * path = @"http://www.AAAAAAAAAAAAAA.com";
[self parseXMLFileAtURL:path];
i++;
}
[self.newsTable reloadData];
}
Now the parsing is happened only one time but the datas are not displayed.
My problem is the tableview does not reload. newsTable is the instance of the Tableview.
How can I achieve this?
Please help me out.
[self.newsTable reloadData];
put this line on click of news button.
it reloads the table view whenever you click. since view did load calls only one time thats why no reload of table view take place.
I suppose, that you are using NSXMLParser.
The parser has a few delegate methods that you'll want to implement:
parser:didStartElement:namespaceURI:qualifiedName:attributes:
parser:didEndElement:namespaceURI:qualifiedName:
parserDidEndDocument:
So, you just need to put reloadData invocation into parserDidEndDocument:
精彩评论