Created
November 18, 2018 18:25
-
-
Save ShoMasegi/175d1e1901c3eac291d0db5201fd318f to your computer and use it in GitHub Desktop.
This file contains 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
import Foundation | |
import RxSwift | |
import SwiftyXMLParser | |
class RadikoService: NSObject { | |
func get(aid: String) -> Single<[Station]?> { | |
return Network.xmlProvider.rx.request(.station(aid: "JP13")) // 東京の番組を取得 | |
.map { $0.data } // Moya.Response -> Data | |
.map { XML.parse($0)} // Data -> XML.Accessor | |
.map { accessor -> [RadikoStation]? in // XML.Accessor -> [Station]? | |
accessor["stations", "station"].map { Station(accessor: $0) } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment