Hi in lesson 11 - https://www.youtube.com/watch?v=7xUSH1QLHzk&list=PLMRqhzcHGw1aLoz4pM_Mg2TewmJcMg9ua&index=11
there have Dictionary to take Json Key, but in youtube used Array - lesson in 2015, i found how to fixed the code, but when I checked string stay empty = “”…
When i checked in debug videoObj have information, but path my be is not corrected if i checked videoObj.videoId = “”, nothing changed.
Can somebody check and help for this code?
func getFeedVedeos() {
//fetch the videos dinamically through the YouTube Data Api
Alamofire.request("https://www.googleapis.com/youtube/v3/playlistItems", method: .get, parameters: ["part":"snippet", "playlistId":UPLOADS_PLAYLIST_ID, "key":API_KEY], encoding: URLEncoding.default, headers: nil).responseJSON { (response) in
if let JSON = response.result.value as? [String:Any] {
var arrayOfVideos = [Video]()
if let videos = JSON["items"] as? [[String:Any]] {
for video in videos {
//print(video)
let videoObj = Video()
if let videoId = video["snippet.resourceId.videoId"] as? String {
videoObj.videoId = videoId
}
if let videoTitle = video["snippet.title"] as? String {
videoObj.videoTitle = videoTitle
}
if let videoDescription = video["snippet.description"] as? String {
videoObj.videoDescription = videoDescription
}
if let videoThumbnailUrl = video["snippet.thumbnails.maxres.url"] as? String {
videoObj.videoThumbnailUrl = videoThumbnailUrl
}
arrayOfVideos.append(videoObj)
}
self.videoArray = arrayOfVideos
}
}
}
}