Reputation: 273
In my map application I am calling web srvice which gives total available results in 5km of radius on map when launch. But If results are not available then it calls bigger radius in which I just want to show nearest 2 results in tableview cell. So how to control the loading of tableview data. Because when bigger radius called data count are 100 and I want only 2 results to display out of 100. Can anyone suggest me logic or tutorial. thanks in advance
Upvotes: 0
Views: 115
Reputation: 4276
If you have searched for the larger radius, return 2 from numberOfRowsInSection
in your UITableViewDataSource
otherwise return the count of your array. As long as your array is in the correct order (distance away) then it will only get called twice and so you will only return the nearest 2.
Because you are still storing all 100, but only displaying 2, that would mean you could then add a "show more" type button which will show the next 10, for example by returning 12 from numberOfRowsInSection
and so on.
Upvotes: 2
Reputation: 920
Why do you want to save all the 100 data in your tableview array/dictionary ? Set a flag to detect whether it is from 5 km radius or greater radius. For the second case, store only 2 results.
Upvotes: 0