Skip to content

Instantly share code, notes, and snippets.

@ShoMasegi
Created November 18, 2018 18:25
Show Gist options
  • Save ShoMasegi/175d1e1901c3eac291d0db5201fd318f to your computer and use it in GitHub Desktop.
Save ShoMasegi/175d1e1901c3eac291d0db5201fd318f to your computer and use it in GitHub Desktop.
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