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?
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
来源:https://stackoverflow.com/questions/11962850/is-there-a-queue-dictionary-for-a-gcd-queue