I am doing multiple HTTP POST to a REST web service that I created. This POST will then translate to an INSERT to a table in the database. The table has a column called ROUTE_ORDER (auto-incremented). This column preserves the order in which the POST was coming in (useful for some other parts of my application), it’s an int which has values of 1,2,3.. etc.
I tried to execute the HTTP POST using CURL of the entries one by one and it works perfectly fine. However I have a loop inside my XCode project, which iterates through an array an do a POST based on the content in the array and the order messed up. Below is the code:
for (Location * loc in [self.data objectForKey:@"route"])
[[RKObjectManager sharedManager] postObject:loc delegate:self];
So my idea is to put a time interval between each iteration of the POST, so that the previous POST finishes first and then goes to the next one and therefore the ORDER is preserved. Question is how can I do this in objective-C? Is this even the problem?
I would suggest, rather than making one request (which can potentially be really large (not sure about your scenario), you can still make multiple requests, but have an order parameter in the request which tells the server what the actual order of the request is, so the server can do behave accordingly