Reputation: 411
I am a newbie to iOS. I have a requirement where I need to fetch data from a local database and upload it to a server. This has to be done in the background when the internet connection is available. How can I proceed on this? I need a kick start.
I read that I can achieve this with help of NSThread, or GCD, but I don't get when each of those is most suitable. Can someone suggest the right way? A sample or pseudocode would help a lot.
Upvotes: 0
Views: 254
Reputation: 1110
here is what gcd code should look like:
dispatch_queue_t queue = dispatch_queue_create("queue_name", 0);
dispatch_async(queue, ^(){
// code
});
Since GCD uses blocks it allows you to capture the state of the local variables.
FYI: You might have searched on Google before posting to stackoverflow. Your query is very common and has been answered before. You might also consider looking at the apple documentation.
Upvotes: 1