UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Marrying multiple http requests with Core Data

Forums > iOS

Hey,

Currently I'm working with an API that (for particular data) doesn't support multiget. So for example, I need to make around 500 requests to get all information about objects tied to my account (amount depending on a user). From that I need to create entities (or update existing ones if changed) in Core Data, to have a local copy.

Since I want to download the data concurrently I don't want to use main NSManagedObjectContext each time data is downloaded or spawn a background context each time I receive response (this would probably create a lot of threads).

How would you best tackle this task? Use OperationQueue/BlockOperation to download the data and when everything is done, spawn a background context (via performBackgroundTask) and store everything to Core Data in one blow (to not cause any merge conflicts too)? Or maybe use DispatchQueue with groups? Or maybe something else?

Thanks!

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.