I am trying to create a Facebook messenger like application from a youtube tutorial. I have a home page where the user click BarButton to open the chats. The Home page works
Seems like you skipped steps in a tutorial which is using Interface Builder.
The problem is, that in your ChatViewController there is a missing connection between your "collectionView?" and the corresponding UICollectionView (so called referencing outlet) in the Interface Builder.
This is a very basic task in iOS development. Please have a look at the official Apple documentation under the topic "Create Outlets for UI Elements": Connect UI to Code