Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Weather App with Swift (Retired) Concurrency Concurrency in Swift

why do we use closures in a cocoa touch framework like said in 1:52 in the concurrency in swift video

anyone?

1 Answer

Jason Wayne
Jason Wayne
11,688 Points

Closures in Swift are similar to blocks in C language and also Objective-C. The benefit is that the functionality can be passed around and use within your code. Also, you don't have to create a whole new function/method in the global scope. Neither do you need to create target-action callback. This mean, you will write fewer codes for the same functionality.