I have created on UITableView, in which, tapping on any of the cell (-didSelectRowAtIndexPath) calls WebService associated with that cell.
Problem is to handle the JSon response, the Request returns.
From where should I handle that response ?
As the view gets changed, as I tap on to the cell of the table (-didSelectRowAtIndexPath); I must pass all the response information to the next view.
Question is : Whether I should call the service after tapping the cell and before the next view getting loaded. Or Stick to this way (Which is making my code unmanageable.)
Which event is the most appropriate to handle this, (-didSelectRowAtIndexPath) or (-viewDidLoad) of the next view ?
Any suggestions?
Thanks.
Once a row has been selected, allocate the NextViewController. Inform the NextViewController that the row has been selected by writing a setter method in NextViewController. In that setter method, start your request. Then push to the NextViewController.
You can handle the webrequest in NextViewController as currently that is being shown, you can reload the view depend on the response.
Edit
If you need to pass any object, pass it to the method. In the method, start the webrequest. And handle the response in the
NextViewController.