To start, this is not a question on regarding how to search or parse using UISearchBar in a UITableView.
I have already set up everything, the parsing, viewing, etc.
My question is, what is the right way to search?
My current flow is:
- Parse the XML.
- Add everything in an array.
- Display the array in the table.
- User input search.
- Parse the XML again using the search input.
- Add everything to the same array.
- Display the array in the table
Is this fine? will this not be slow when it is on a real server? is it doing too much request?
OR this would be a better approach?
- Parse the XML.
- Add everything in an array.
- Display the array in the table.
- User input search.
- Search the array.
- Create a new array and add the searched items.
- Display the new array.
Thanks!
Technically both the approaches are fine. However, as far as the performance is concerned, it is usually advisable to avoid repeated calling of the web service. Unless the data of your web service is changing, it is preferred to save the data from the web service in some variable (array in your case) and then use this array to access the web service data again.
Therefore, I would suggest that you should use the second approach. I will be computationally less expensive.