Thank you for the explanation of the GCD, I really appreciate that. I have a question on section Concurrency Looping. What does the following line does?
This is great stuff. Exceptional. I started on this āthread of GCDā with closures; my situation is like that of of a network async behavior but where operation completion is completed in a different method. While I knew Iād be using GCD, I expected to be using āescapeā closures. Here is my first question: isnāt some of the synchronization (dispatch_group) a replacement for what could be an escape closure?
Second, and my comments are meant as feedback, introducing semaphores at the end while obviously related to synchronization is tangential to your target. GCD and dispatch is right on. Why is that? Answer: my experience is that the lesson here isnāt easily transferred to say command line. Oh, I know it compiles, but the lack of the iOS āmain threadā and managed memory will require more work. Consider the application programmer that wants to use these lessons (knowing only swift as their model of execution) across the systems (command line, cocoa, and then iOS). Isnāt GCD and dispatch meant to replace the old-school synchronization objects?
I have an iOS app written in Swift 3. in one of the modules i need to upload several files into a Web Server concurrently (files are chosen by the user from camera or gallery). i also have to display progress indicator for each file that indicates when upload is in progress and when upload is completed. the files are about 3-4MB each and the number of files is unknown (depends on the user) .
My Question:
should i use the low level GCD api or the higher NSOperation/NSOperationQueue abstraction ? I have searched a lot but some got mixed answers (some say GCD and other say NSOperationQueue).iāv been struggling with this question a lot and i donāt want to start coding only to find out in the end that i picked the wrong approach. (multi-threaded code is challenging anyhow)
Hi, accord to this mail list thread, it is done to specify the queue that will be used by concurrentPerform, but I just tested it and use another, I donāt know how itās selected because is not even the same queue where concurrentPerform was called. I also would like to know certainly what is this for and how to specify a queue to use.
This is meant to specify the Quality of Service class to use, matching the prior steps.
@pistach, I just read up on escape closures. It does look very similar to Dispatch Group. So here Iād agree with you, you could probably use that instead. Itās worth trying. I didnāt quite get your second piece of feedback. Could you elaborate further?
dannofx, itās my understanding that this would set the QoS which in turn would guide GCD into picking a high priority queue. What queue did you see being used?
I would start with the higher abstractions unless you get stuck and really need to delve into the lower level APIs. If you havenāt already made a call on the direction to go, that would be my suggestion.
This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]