Search code examples
iosswiftxcodexcode9

What to check when outlet detection is not working?


I'm not sure what I did wrong, but I tried to connect the outlet from my main storyboard to my new ViewControllerTableViewCell.swift that I just created.

I set the class to ViewControllerTableViewCell

enter image description here

It contains

import UIKit

internal class ViewControllerTableViewCell : UITableViewCell {

    override internal func awakeFromNib()

    override internal func setSelected(_ selected: Bool, animated: Bool)
}

Now, I open up my Main.storyboard and attempting to drag my image and label

enter image description here

I did't see the auto detect come up.

However, when I tried to drag those into my ViewController.swift, it works. To make sure it is not XCode Caching issue. I also restart my XCode, and still face same issue.

I was hoping to see something like this

enter image description here

How do I check further to make this work again?


Solution

  • Good question. That's one of the disadvantages of using the interface building. But anyways, here's a solution:

    1. Make sure that your custom tableView class, ViewControllerTableViewCell is assigned to your custom cell in your storyboard, like so:

    enter image description here

    1. Then, click on the automatic thing above, and see if you're viewing the cell class.

    2. Try again now to have an outlet.

    Also, CMD+B (building) helps the Xcode to correct some things.

    enter image description here