3

I would like to know if there is a way in Objective-C to get a thread by its name or label?

dispatch_queue_t newQueue = dispatch_queue_create(@"NameOfTheQueue", NULL);

This creates the queue. So, in another module, is there a way to get that queue?

Something like:

dispath_queue_t theQueue = dispatch_find_queue_by_name(@"Name...");
kb920
  • 3,039
  • 2
  • 33
  • 44
Jeff
  • 39
  • 2

2 Answers2

0

This is not possible, as the names need not be unique.

Eiko
  • 25,601
  • 15
  • 56
  • 71
0

No, there is nothing built into the Dispatch functions that let you find a queue other than the main queue.

You could write your own little wrapper that stores queues and their names in a dictionary for lookup. But keep in mind that a queue's name doesn't have to be unique.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 1
    ... and if you're storing the queue in a dictionary, you could just store the reference in a more meaningful (direct) way right away. :) – Eiko Oct 14 '16 at 20:12