Cyril
Cyril

Reputation: 2818

Populating tableView inside a collectionViewCell

I am trying to create a UITableView inside a UICollectionViewCell. My goal is to implement a tableview inside my CollectionViewCell and populate my tableView with simple data. I want to create pages of tableViews populated with different categories of data.

I thought it would be a relative easy task, however I am getting a Threat 1: signal SIGABRT error. The debugger is prints

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:

'-[TableViewMockUp.ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x100b07cc0'

I am not sure what this error is telling me. When I look inside my ViewController I don't have a tableView numberOfRowsInSection method.

I have the project on Git if you want to take a look: https://github.com/cyrilivargarcia/TableViewMockUp

Below is a snapshot of my ViewController class enter image description here

This is a snapshot of my CollectionViewClass which is where I created my TableViews. enter image description here

Any idea on how I can resolve this problem?

Upvotes: 0

Views: 281

Answers (1)

DonMag
DonMag

Reputation: 77681

-[TableViewMockUp.ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x100b07cc0

I am not sure what this error is telling me. When I look inside my ViewController I don't have a tableView numberOfRowsInSection method.

You've hit the nail on the head. The error is telling you "you don't have a numberOfRowsInSection method", and your reply is "I don't have one".

So... you just need to add that method to your view controller :)

Edit: After reviewing your code, to clarify for your specific case...

You had your TableView Delegate and DataSource connected to the wrong thing.

  • In IB, select your table view...
  • In the Utilities pane, select the Show Connections Inspector
  • Click the little "x" to delete the current Delegate and DataSource connections
  • Drag to the CollectionCell in the Document Outline tree

That should do it!

Upvotes: 1

Related Questions