ARGH!! - XMLParsing and selector delegate functions
Hello all,
Right, this is my first post, so please dont blast me if this is in the wrong section. ;-)
Right, so we have built an iphone app called "The NightLife Bible by NightOutGroup" and its approved and in the app store.
We are trying to make some updates for version 2 but are having some difficulty.
Feel free to download v.1.1 if you like, to get a feel for the app - it is completely free.
In crude terms the part of the app giving me problems currently does the following:
I have a tableViewController inside a TabBarController.
The TVC pulls an xml feed from one of our web services listing all the Nightclubs and venues in Sunderland, and displays the data inside the TVC. (This feed collector is pretty much a copy of the seismic demo from Developer.Apple - No point re-inventing the wheel)
From there, the tableViewController rows are clickable to get further info about the venue.
All fine and dandy, and works fine.
That is version 1 which just works for Sunderland.
For Version 2 We have added a settings page where you can select a city, and it stores the city in the AppPreferences.
This city value is then used in the NSURL RequestString bit to get the xml and return it.
Again all this fine, and the correct venues are returned for each city.
The problem is this:
If you change the city, the screen did not refresh.
So i moved the XML getter function from viewdidload to viewdidappear, and did some checks for to make sure the cities are not the same, to prevent reloading data from the same city.
This now runs the functions, mostly as expected, and returns the data!
For some reason, when the city is changed, one call is made to the xmlparser, as should happen, but the "insertEarthquaqes" delegate selector method is being run multiple times.
It works propperly the first time,
returns 2 sets of the same data the second time,
3 sets the 3rd time...
and so on.
This is not because i am forgetting to remove the existing data. I am removing all data from the TVC and the dataset at the start of the refresh function. - The multiple sets of data are not the old and new lists of venues, but the new set of venues multiple times...!
The Update Function is only called once.
The XML is only being collected from the server once
The XMLparser is only called once.
The List of venues is only being created once.
The insertVenues (or insertEarthquakes as it is called in the demo code) selector delegate method is being called the same number of times the view has been refreshed. Thus returning the same set of data, which is always correct, that number of times.
!!!!! Everything only runs once (as far as i can see) except the "insertEarthquakes" selector method, which is running the number of times the refresh is happening, and then adding that number of sets of complete results (venues)!!!!!
It is driving me mad! I have been on this for a week.
I then tried manually re-calling the function using a button and the same happens. If it is clicked multiple times, then you get the same number of multiples of correct results displaying.
It seems to know how many past requests for the data were made, and running the selector delegate function that many times!
Please can someone help. Its driving me MAD!!!
I will post the code as soon as I can.
|