YouTube App - Lesson 5 TableCell does not display data

Hey guys,

I just did the lesson 5 on YouTube App, but seems like at the end of the lesson, My tableView does not display the title of the video. I am pretty sure I have the same code like Chris has.
Can anyone help me why my tableView is not displaying the title of the video?

Below, I attached the picture of my code.
Response Struct

ViewController

class Model

Thank you in advance!

Best,
Justin

Hi Justin,

Hmmm looks good to me.

Were you getting the data correctly from lesson 4 when dumping the response?

PS you should capitalize the M in ModelDelegate because that’s convention

Hey @MikaelaCaron,

Thank you for the respond.

When I tried to put a break point on the dump, It actually did not hit the dump(response). It hitted the catch block. so there must be an error on the do {} block. I am note sure what though…

I am pretty sure I have the correct Video class.

Best,
Justin

I have same error!

0x7fff5234ba6b <+0>:   cmpq   $0x0, 0x37b55235(%rip)    ; gCRAnnotations + 7
0x7fff5234ba73 <+8>:   jne    0x7fff5234ba83            ; <+24>
0x7fff5234ba75 <+10>:  leaq   0x67ea(%rip), %rax        ; "__abort() called"
0x7fff5234ba7c <+17>:  movq   %rax, 0x37b55225(%rip)    ; gCRAnnotations + 8
0x7fff5234ba83 <+24>:  pushq  %rbp
0x7fff5234ba84 <+25>:  movq   %rsp, %rbp
0x7fff5234ba87 <+28>:  pushq  %r15
0x7fff5234ba89 <+30>:  pushq  %r14
0x7fff5234ba8b <+32>:  pushq  %r12
0x7fff5234ba8d <+34>:  pushq  %rbx
0x7fff5234ba8e <+35>:  subq   $0x20, %rsp
0x7fff5234ba92 <+39>:  leaq   -0x30(%rbp), %r12
0x7fff5234ba96 <+43>:  andq   $0x0, -0x8(%r12)
0x7fff5234ba9c <+49>:  movl   $0xffffffff, %eax         ; imm = 0xFFFFFFFF 
0x7fff5234baa1 <+54>:  movq   %rax, (%r12)
0x7fff5234baa5 <+58>:  pushq  $0x6
0x7fff5234baa7 <+60>:  popq   %r15
0x7fff5234baa9 <+62>:  leaq   -0x38(%rbp), %r14
0x7fff5234baad <+66>:  movl   %r15d, %edi
0x7fff5234bab0 <+69>:  movq   %r14, %rsi
0x7fff5234bab3 <+72>:  xorl   %edx, %edx
0x7fff5234bab5 <+74>:  callq  0x7fff522e185c            ; sigaction
0x7fff5234baba <+79>:  andb   $-0x21, 0x8(%r14)
0x7fff5234babf <+84>:  leaq   -0x24(%rbp), %rsi
0x7fff5234bac3 <+88>:  orl    $-0x1, (%rsi)
0x7fff5234bac6 <+91>:  pushq  $0x3
0x7fff5234bac8 <+93>:  popq   %rbx
0x7fff5234bac9 <+94>:  movl   %ebx, %edi
0x7fff5234bacb <+96>:  xorl   %edx, %edx
0x7fff5234bacd <+98>:  callq  0x7fff5234c712            ; symbol stub for: sigprocmask
0x7fff5234bad2 <+103>: pushq  $0x1
0x7fff5234bad4 <+105>: popq   %rdi
0x7fff5234bad5 <+106>: callq  0x7fff5234c26e            ; symbol stub for: __pthread_workqueue_setkill
0x7fff5234bada <+111>: movl   %ebx, %edi
0x7fff5234badc <+113>: movq   %r12, %rsi
0x7fff5234badf <+116>: xorl   %edx, %edx
0x7fff5234bae1 <+118>: callq  0x7fff5234c69a            ; symbol stub for: pthread_sigmask
0x7fff5234bae6 <+123>: callq  0x7fff5234c68e            ; symbol stub for: pthread_self
0x7fff5234baeb <+128>: movq   %rax, %rdi
0x7fff5234baee <+131>: movl   %r15d, %esi
0x7fff5234baf1 <+134>: callq  0x7fff5234c64c            ; symbol stub for: pthread_kill
0x7fff5234baf6 <+139>: movl   $0x2710, %edi             ; imm = 0x2710 
0x7fff5234bafb <+144>: callq  0x7fff522fd648            ; usleep$NOCANCEL
0x7fff5234bb00 <+149>: movl   $0xffffffe7, 0x8(%r14)    ; imm = 0xFFFFFFE7 
0x7fff5234bb08 <+157>: movl   %ebx, %edi
0x7fff5234bb0a <+159>: movq   %r12, %rsi
0x7fff5234bb0d <+162>: xorl   %edx, %edx
0x7fff5234bb0f <+164>: callq  0x7fff5234c712            ; symbol stub for: sigprocmask

-> 0x7fff5234bb14 <+169>: ud2

Thread 7: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

bro it is work with me when I did this

DispatchQueue.main.async {
self.tableView.reloadData()
}

@justin.huang12 watch video 4 again.

Make sure you are getting the data correctly.

If you can’t get the data, then it’s not going to display properly

I’d begin by checking your URLs making sure those are correct

Hello @MikaelaCaron,
I am pretty sure the urls in the constant class is correct.

Below is a picture of what happen when I run the program. it hitted the
let response = try decoder.decode(Response. self , from: data!)
but does not hit the dump(response). Do you know what usually the cause of this problem?

Thank you very much.
best,
Justin

Hey @Abu_Mukhlef, thank you for responding.

Unfortunately I tried your way and it is still not working.

Thank you though for your willingness to help me.

Best,
Justin

Can you zip the project and upload it here? I can take a look. I already completed this and it works fine for me.

Also @justin.huang12 tag me when you upload your code, sometimes my browser won’t notify me of some messages

Hello @MikaelaCaron,
I apologize for the super late reply. Hopefully you are still willing to help me. I will really appreciate it. Looks like this site does not allow me to upload a zip file. So I uploaded my file on github without my API key, and here is the like to the repository:

Thank you so much for your willingness to help me.

Best,
Justin

Hi Justin,

I just downloaded your project and added a playlist ID and my API key I used for my version and it works OK. Here’s a screen dump of the output.

This is what your Constants file now looks like (minus the API key).

struct Constants {
    static var API_KEY = "apiKeyRemoved"
    static var PLAYLIST_ID = "PLMRqhzcHGw1aLoz4pM_Mg2TewmJcMg9ua"
    static var API_URL = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=\(Constants.PLAYLIST_ID)&key=\(Constants.API_KEY)"
    
    static var VIDEOCELL_ID = "VideoCell"
}

Hey @Chris_Parker,

Thank you. Good to know that it actually works. I might have to check my api key, playlist id, and url.

Thanks again!

Best,
Justin

Update: Turns out I actually haven’t put the Playlist ID. no wonder it was not fetching to the correct url. Now It work complete fine.

Many thanks,
Justin