March 2017
Intermediate to advanced
264 pages
7h 26m
English
To try out closures, we are going to call addPeriodicTimeObserver(forInterval:queue: using:), passing in a closure to call repeatedly when our podcast is playing. There’s a little housekeeping we have to do for this approach: the docs say that the return value is an object of type Any that we will eventually provide to removeTimeObserver to stop our updating. So, with the other properties near the top of ViewController.swift, add a property where we can hold on to this object. It’ll need to be an optional, since we won’t actually create it until long after init is done.
| | private var playerPeriodicObserver : Any? |
We already cleaned up the player
Read now
Unlock full access