3

I have three background tasks

  • Task 1 is to upload data of type 1 (say)
  • Task 2 is to upload data of type 2 (say)
  • Task 3 is to upload N number of images.

I want all tasks to run with priorities.

  • Task 1 has the highest priority
  • Task 2 with lower priority
  • Last, uploading of images in lowest priority

Is there any way I can put all these request in different queues with different priorities?

I am Using Swift 2.2 and pointing to iOS 8.0 and above.

Willjay
  • 6,381
  • 4
  • 33
  • 58
iAviatorJose
  • 418
  • 2
  • 10
  • 25
  • you can use NSOperationQueue. – Willjay Sep 05 '16 at 03:52
  • you can use GDC's QoS class or [global queue priority](http://stackoverflow.com/questions/25052629/ios-gcd-difference-between-any-global-queue-and-the-one-with-background-priorit) – Tj3n Sep 05 '16 at 04:19
  • just wondering what was your final solution – XcodeNOOB Nov 27 '18 at 08:58
  • @XcodeNOOB i used the GCD QoS classes to achieve this, (To learn more about GCD Queues go here https://www.raywenderlich.com/5370-grand-central-dispatch-tutorial-for-swift-4-part-1-2) here in GCD we have different global queues that run according to their priority, i ran this first two task in Utility Queue and then the synced the images in Background (Queue with lowest priority) Queue. – iAviatorJose Nov 27 '18 at 10:29
  • I see, I think the better approach will be to combine OperationQueue with GCD... thank you – XcodeNOOB Nov 27 '18 at 10:50
  • @XcodeNOOB OperationQueues and GCD whichever suits your situation, you can go thorugh this article in your free time https://cocoacasts.com/choosing-between-nsoperation-and-grand-central-dispatch/ – iAviatorJose Nov 27 '18 at 11:30

0 Answers0