What We’ve Learned

In this chapter, we looked at the last of the major Swift types: closures. A closure is a type that contains executable code, capturing any variables that are in scope at the time of the closure’s creation and are used in its code.

With the ability to treat executable code as just another “thing” that we pass around in our app, we open up new ways to express ourselves, and allow ourselves to use powerful and cleaner asynchronous APIs in the iOS frameworks than were possible with callback-driven approaches like Timers and key-value observing.

We used a closure to update the player’s time label at specific intervals, and also investigated UIKit’s paramount rule about accessing the user interface only from the main GCD queue.

Now that we have a functional player scene and the ability to handle asynchronous code, it’s time for our podcast app to start getting real. In the next chapter, we’ll go out to the network, pull down real podcast feeds, and parse them into native Swift types.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset