Thomas_LEB
Thomas_LEB

Reputation: 239

IOS Application: Sending data to web server constantly

I'm working on an application which has to send data to a web server constantly.  I will be sending text data they should be submitted to the web server as they are made available

Like a queue First in first out

In case a request fails to go through, it should retry to resubmitted it before jumping to the next request.

 all the operations should be done in the background, and not interrupt the main application

What is the best way to implement this

Upvotes: 0

Views: 710

Answers (2)

rob mayoff
rob mayoff

Reputation: 385600

Create a Grand Central Dispatch queue, and add a block to the queue for each message using dispatch_async. Each block can send its message synchronously and retry until it succeeds.

Dispatch Queues in Apple's Concurrency Programming Guide

There are two videos about GCD from WWDC 2010: Introducing Blocks and Grand Central Dispatch on iPhone and Simplifying iPhone App Development with Grand Central Dispatch. There's also a video from WWDC 2011: Blocks and Grand Central Dispatch in Practice.

Upvotes: 0

Caleb
Caleb

Reputation: 124997

Like a queue First in first out

So use a queue. Add messages at the tail of the queue. Have a background thread remove messages from the front of the queue, send them, verify that the data was transferred successfully, and move on to the next message. You'll want to make sure that you access the queue in a thread-safe manner from all threads that use it.

Upvotes: 3

Related Questions