Wednesday, 15 September 2010

ios - Should I explicitly handle an interrupted asynchronous process when switching view controllers? -


I can not understand this question enough to get useful search results.

If I wait for a network connection to finish, change the most important view controller, should I create error handling around the network request? Or can I expect the callback block to be the message zero and nothing else? Or is there a preprocessor magic that humbly closes the process?

Is not the above answer for all the processes on the main thread?

If the representative of the asynchronous request is a view controller, then you should cancel the request and that administrator is inactive Used to be.

If you do not cancel the request, you are trying to do things that are no longer relevant to the user. Once we had this problem and users were watching pop-up alerts Were not relevant.

If you are using NSURLConnection , then just type the code at . You'll usually have to keep a strong indicator for the NSURLConnection object so that you can do it.

A good place to cancel the request prepareForSegue before switching to another view.

With a navigation controller (push sensu) or a model segu, the view controller is placed on the stack, so it will not be released. Your representative method will still be called. Even in other circumstances, you can participate in the race conditions, so always cancel.

You should consider canceling the request in your view controller's VisualWillDeediacier method. If the user clicks the Home button before receiving the request, then returns to the application, the request will be the most error (time out). If you are not doing anything in connection errors, then you are good, but if you are displaying an error, then users will not expect to see an error after relaunching the app.

Considering the MVC model, the answer to all the processes related to a particular perspective is very similar.

In some cases, the representative requesting asynchronous request can be an example of a separate class (see no controller), and instead of canceling, you always respond to the same thread (main run loop) Will process. I do this when I am updating the "background" content.

No comments:

Post a Comment