Hi, during the lesson 6 of the Youtube App around the 22-minute mark Chris demos the thumbnail images, title and date. For some reason, I run the app and it comes up as blank images and no labels.
I’m not sure what this error means if it means anything at all. This happens after the line:
func setCell(_ v:Video) {
//Ensure that we have a video
guard self.video != nil else {
return
}
If I set a breakpoint before that the debugger works. I’m sure that I have videos because before I made the VideoTableViewCell.swift file the simulator was accessing the titles to the videos just fine. I’m not sure what could be the issue. Here are images in case they are helpful.
In your setCell function when the breakpoint stops at the line self.video = v
In your Console where you see the (lldb) in green, type:
po v.thumbnail
and press return to see if there is a value returned which should be a url to the video thumbnail. That will at least prove that there is a video url being returned.
What does the rest of your setCell code look like? Have you added all the code that downloads the image data in the URLSession?
Also, what does your cellForRowAt code look like in your ViewController.swift file?
By the way, you can embed images in your post by either dragging them I’m and dropping them at the point you want or you can tap on the image icon and select the image from Finder.
I’m away from my laptop at the moment but if you want to share your project on DropBox by posting a link to it in a reply, I can have a look at it tonight my time which it UTC + 8 or +12 New York time
Thanks man, I really appreciate that. Sorry for the late response I was away from home. No rush, just whenever you have a minute. I’ve removed the API key so you may need to add your own.
func setCell(_ v:Video) {
//Ensure that we have a video
guard self.video != nil else {
return
}
self.video = v
//Set the title label
self.titleLabel.text = video?.title
.
.
.
.
and what was happening is that the test on self.video was always going to be nil because video was not being set. The following line of code self.video = v needed to be before it. So your code should have been like this:
func setCell(_ v:Video) {
self.video = v
//Ensure that we have a video
guard self.video != nil else {
return
}
//Set the title label
self.titleLabel.text = video?.title
.
.
.
.