views:

364

answers:

1

Hi, 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 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 doesnot reload. newsTable is the instance of the Tableview.

How can i achieve this.

Please help me out.

Thanks.

A: 

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:

kovpas
He has checked for a "if" condition with static variable "i" so for the second time the control will not go inside that "if" loop.So then whats the use of NSXML Parser delegate methods.
Warrior