raheel
raheel

Reputation: 1415

Is there a queue dictionary for a GCD queue

I am quite fond of the threadDictionary property in NSThread: very handy to store things with per-thread ownership.

Is there an equivalent dictionary for a GCD queue?

Upvotes: 4

Views: 686

Answers (2)

borrrden
borrrden

Reputation: 33421

If you can target iOS 5 and above, you can use dispatch_queue_get[set]_specific() which allows you to add dictionary-style (i.e. keyed) values to a queue. I can't find the document pages on them, strangely enough, but they are commented in queue.h

Upvotes: 4

Robotic Cat
Robotic Cat

Reputation: 5891

You might want to look into dispatch_set_context/dispatch_get_context. Documentation here and here. You have to manage the context but it might be what you're looking for.

Upvotes: 3

Related Questions