Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is equivalent of "dispatch_apply" in Swift 3?

Tags:

ios

swift

swift3

I have been searching for an equivalent of dispatch_apply in swift3. Help me please

convert

    let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_apply(2, queue) { (index)  in
    }
like image 297
venky Avatar asked Sep 20 '16 09:09

venky


1 Answers

Do you still remember dispatch_apply(). Well, it's still there and got a new name. From now on you have to call concurrentPerform()

change this

dispatch_apply(2, queue) { (index)  in
}

into

DispatchQueue.concurrentPerform(iterations: 2) {
print("\($0). concurrentPerform")
}
like image 158
Anbu.Karthik Avatar answered Oct 20 '22 19:10

Anbu.Karthik