Created
June 22, 2018 10:56
-
-
Save desmondmc/1dc49bb2bd53058ad04e9eb6402f3e57 to your computer and use it in GitHub Desktop.
requestStations fails if initialize was called without a connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func initialize(_ token: String, secret: String) { | |
FMAudioPlayer.setClientToken(token, secret: secret) | |
} | |
func requestStations(stationsCallback: (Stations) -> ()) { | |
FMAudioPlayer.shared().whenAvailable({ | |
guard let stations = FMAudioPlayer.shared().getAllStations(options: [:]) else { | |
// throw error | |
return | |
} | |
let stationInfo = stations.map { | |
["name": $0.name, | |
"identifier": $0.identifier] | |
} | |
stationsCallback(stationInfo) | |
}) { | |
// throw error | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment