Cannot Add Identity to Custom Class

I'm trying to teach myself Swift using the "App Development with Swift" book. I've gotten to Chapter 4: Tables and Persistence and am working my way through the Emoji Dictionary app.

I'm trying to customize a table cell. The book tells me to create a custom Cocoa touch file, and then add that to the Class identifier under the Identity inspector - but the file name does not show up under the drop-down menu.

I have tried quitting Xcode and starting again, I've tried deleting the file and adding it again, I've searched the web and though I found a similar question on StackOverflow, the solution there did not work.

This is driving me bonkers and I can't complete the assignment. Any help would be very appreciated.

Answered by OOPer in 642673022
@GryphonDreaming

Here is its declaration:
class EmojiTableViewCell: UITableViewController {}

All table view cell types need to be a subclass of UITableViewCell, not UITableViewController.
Can you show how you defined the class ?

Should be like

Code Block
class MyTableViewCell: UITableViewCell {
}


Then, in IB, select the tableView and select "Cell", the first level of its hierarchy

TableView
  > Cell
  > contentView

When no class is defined yet, it should show the default placeholder "UITableViewCell".
Then you should be able to set the class to MyTableViewCell

If that does not work, do an option-clean build Folder (Product menu)
When I added the Cocoa Touch Class file, it defined the class for me. Here is its declaration:

Code Block
class EmojiTableViewCell: UITableViewController {}


I did select "Cell" in interface Builder as you suggested, but nothing shows up in the drop-down.

I did try the Option Clean Build, but nothing happened.

Further - I've tried restarting the computer, and setting up a completely new project from scratch. Neither fixed the issue.

Accepted Answer
@GryphonDreaming

Here is its declaration:
class EmojiTableViewCell: UITableViewController {}

All table view cell types need to be a subclass of UITableViewCell, not UITableViewController.
That did it - thanks, OOper!
@GryphonDreaming

That's what I told you:

the class should be like
class MyTableViewCell: UITableViewCell {}


Do you read the post ?
I did, Claude, thanks, but I missed the salient point in your post just as I missed it when creating the Cocoa Touch Class file in the first place.
Cannot Add Identity to Custom Class
 
 
Q