Aravind
Aravind

Reputation: 845

Confusion regarding ->> dispatch_queue_create ...?

Currently in my code am using

dispatch_async(dispatch_queue_create("myQueue", nil) , { () -> Void in

Now I have the necessity in my code to call this code many times ...

So my question is whenever each time I call the above mentioned statement I want to know whether am posting the task to the same queue or each time when I call am creating a new queue ??

Pls guide me if any one came across the same problem...

Thanks in advance...

Upvotes: 1

Views: 329

Answers (1)

Vinay Jain
Vinay Jain

Reputation: 1661

As the queue you are creating is local to the scope of method from where you are calling it, you can not get any detail of the queue after the method is executed.

What you can do is create this queue as a global variable out of all methods. Thus your queue will be created only one time

let myQueue : dispatch_queue_t = dispatch_queue_create("myQueue", nil)
.
.
.
.
// then you can use it in this way anytime you want:

dispatch_async(myQueue , { () -> Void in

Upvotes: 1

Related Questions