Open Fendo181 opened 7 years ago
SwiftJSONを使って以下のように取得する事ができる事がわかった。
let track_name = json["items"][0]["track"]["name"]
let album_name = json["items"][0]["track"]["album"]["name"]
let imgURL = json["items"][0]["track"]["album"]["images"][1]["url"]
let track_url = json["items"][0]["track"]["preview_url"]
SpotifyPlayモデルを作って最終的にはこんな感じに取得するようにした。
static func fetchPlaylist(handler: @escaping ((spotifyPlaylist) -> Void)) {
spotifyAPIRequest(OathToken: OathToken!, playlistID: playlistID!){ json in
let tracks = spotifyPlaylist(
track_name: json["items"][0]["track"]["name"].stringValue,
album_name: json["items"][0]["track"]["album"]["name"].stringValue,
imgURL: (json["items"][0]["track"]["album"]["images"][1]["url"].url)!,
track_url: (json["items"][0]["track"]["preview_url"].url)!
)
return handler(tracks)
}
}
困っていること
Playlist’s Tracks
のデータをカスタムビューセルに表示したいが、データが多すぎる。多い。ので必要なデータだけを取り出す。サンプル
ゴール
相談したいこと
(ゴールにいたるために、悩んでいること、決めて欲しいこと、助言してもらいたいことを書きます。)
関係者
@Komei22