I have a webservice that returning 20 results each time (it is a limitation of the service provider). I want to call this service 10-20 times repeatingly and update my UI each time.
Is there best practice for this situation? I do not want to block the ui while calling the server. This causes problems if the user want to perform actions while the action in progress
(like navigating away from the current page)
Thanks!!!
I have a webservice that returning 20 results each time (it is a limitation
Share
what you can do is call the webservice in a background thread, collect the required data and jump back to main thread and update the UI.
We are doing the above(i.e jumping from background thread to main thread) because it is not recommended to update any UI in the background process.
you can call you webService in background by using
[self performSelectorInBackground:@selector(MyWebService) withObject:nil];//you can pass any object if you haveand to come back on main thread when the background task is over you can do..
[self performSelectorOnMainThread:@selector(myMainFunction) withObject:nil waitUntilDone:YES];you can change the last parameter i.e.
waitUntilDone:Noalso. By doing this, user will not have to wait till the UI is updated. they can carry there task.you can use
NSTimerfor periodic calling your webService.hope that helped 🙂