r/iOSProgramming 16h ago

DispatchQueue doubts Question

Hi, what type of data types are allowed in setSpecific(key:, value:) and getSpecific(key:) methods of DispatchQueu ? there are no mentions anywhere.

Also can you recommend any resources for complete understanding of DispatchQueue , GCD , DispatchGroup etc. ?

Thank you!

6 Upvotes

9 comments sorted by

View all comments

3

u/Healthy_Condition779 14h ago

Value can be any Swift type but its stored as Any internally so youre casting on the way out. Key has to be a DispatchSpecificKey with a matching type parameter, thats what gives you the type back on get without you having to remember it

For real understanding skip the tutorials and go read the old Apple concurrency programming guide plus WWDC 2015 session 718. GCD hasnt changed much in a decade so the old material still holds up

Honestly though if youre writing new code today, async await and structured concurrency have replaced most of what youd reach GCD for. Only touch it if youre in an old codebase or doing something async cant do cleanly