Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 569493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:18:03+00:00 2026-05-13T13:18:03+00:00

Imagine a table view listing some recipes. Each time the user taps on a

  • 0

Imagine a table view listing some recipes. Each time the user taps on a recipe a new table view is loaded listing recipe ingredients.

To get the information, I’m asynchronous calling a REST API using:

NSURLRequest *request = [NSURLRequest requestWithURL:url
                                      cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                      timeoutInterval:30];

When user taps on a recipe, a call to the API is made to get recipe ingredients. However, once in the new view (which list ingredients) and before the answer is received, the user can go back and select a new recipe.

In this case, I’ll receive two answer; one for each request. The problem is I don’t know to what request is this answer for and I’ll refresh UI with a wrong content from a wrong answer.

I’m not sure which is the right approach in this case. I’m thinking about including in the answer each request parameter. So, if I’m, for example, using the API to search for certain term, we say "foo", I’ll include the term in the answer too, for example:

Request:

http://example.com/api/search?term=foo

Answer

{
"requestType": "search",
"term": "foo",
"result" : "a foo result"
}

It looks strange to me to include each request parameter on each answer, but it is the only solution I found to create a stateless API ready to be called asynchronous.

Is there any other way of accomplishing this?

(I’m using a delegate pattern assigning an object to each request which is called when the answer is received. The problem is, in the example of recipes, that the ingredients table view is reused each time recipe ingredients are listed).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:18:04+00:00Added an answer on May 13, 2026 at 1:18 pm

    One possibility is to include a unique “request ID” in the request, and for the server to echo it. Then the server doesn’t need to return all the request parameters, just the request ID. The client would generate a new ID for each request, possibly using something as simple as incrementing an integer.

    Another possibility is to create a “cancelable asynchronous request”. When you issue the request, return an object that can be used to cancel the request. If the request is cancelled before the delegate is fired, then ensure that the delegate won’t be fired. When a response comes back for a canceled request, just throw it away. For your ingredients table, before you issue a new request, you cancel any pending request (so that you have at most one uncancelled request at a time).

    One way to implement this is to build a two-stage callback. The first callback, which is managed by the infrastructure, just checks to see if the request was cancelled. If not, it goes on to call the second callback (which is actually your delegate).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 307k
  • Answers 307k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Similar to what @ZippyV wrote, you can just use an… May 13, 2026 at 9:35 pm
  • Editorial Team
    Editorial Team added an answer Theres examples of iterating through messages here and doing multiple… May 13, 2026 at 9:35 pm
  • Editorial Team
    Editorial Team added an answer Change the order of :last and :not(): $('#menu li:not(.ignore):last') May 13, 2026 at 9:35 pm

Related Questions

I know that there are a few questions like this on SOF, but I
I imagine this is pretty dead-simple, but somehow I haven’t been able to get
Have you ever seen any of there error messages? -- SQL Server 2000 Could
I have a table that has a view_count column. I would like to increment
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.