iphone - asynchronous stateless API -


Imagine the table view listing some recipes, each time a user taps on a recipe, a new table view Loading Listing Acquisition Content

To get the information, I am doing a REST API using an asynchronous phone:

  NSURLRequest * request = [NSRR request request with url: URL cache Policy: NSURASTRLOD unauthorized local cachedata timeout interval: 30];  

When a user taps on a recipe, a phone recipe for the API is done to get the content. However, once more answers are received in the new view (list list content), the user can go back and choose a new recipe.

In this case, I repeat the two answers; One problem for each request is that I do not know what the response is, and I will refresh the URL with the wrong content from the wrong answer.

I'm not sure what is the correct approach in this matter. I am thinking about adding in response to each request parameter. So, for example, if I am using API to search for a certain period, then we say "Foo", I will also include the word in the answer, for example:

Request: "search", "word":

Answer

  {"RequestType": "search" "foo", "results": "a foo result"}  

I feel strange to include every request parameter on each answer, But this is the only solution that I A

¿Is there any other way to accomplish this?

(I am using a delegate pattern which provides the object to each request that is called the answer. The problem is that in the example of recipes, the content table reuse will be used again. It is done, time schedule components are listed).

There is a possibility to include a unique "request id" in the request, and to resume the server Then the server does not need to return all the request parameters, only the request ID client will generate a new ID for each request, possibly using something as an extension to increase an integer.

Another possibility is a "cancelable asynchronous request" when you issue a request, return the object that can be used to cancel the request. If the representative is removed, then the request is canceled, so make sure that the representative is not removed. When a reaction comes back to a canceled request, throw it away. For your content table, before issuing a new request, you cancel a pending request (so that you have a canceled request at no time without request).

One way to implement it - two-stage callback first callback, which is managed by the infrastructure, checks to see if the request was canceled. If not, it calls the second callback (which is actually your representative).


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -