Price Garrett
Price Garrett

Reputation: 35

Class won't populate in Identity Inspector Xcode

I'm having a repeating problem in Xcode and would like to ask for help/advice.

Have been creating a new class, FirstViewController, which is a subclass of UIViewController. When I go to the Identity Inspector to layout the .xib file, so that I can layout my objects and make my connections.

But FirstViewController doesn't show up in the dropdown list for Custom Class in Identity Inspector.

What am I doing wrong, and what can I do to fix this?

Thanks in advance.

I have tried to clean and rebuild project, highlight File owner and then choose Custom Class, restart Xcode, and restart my computer... but to no avail!

Upvotes: 1

Views: 2481

Answers (3)

mercury
mercury

Reputation: 2755

The problem with me was that the storyboard view was a table view controller , but the class does not inherit from the UIViewController .

Just make sure that your view has the right inheritance class as the same storyboard view .

Upvotes: 0

Ethan Parker
Ethan Parker

Reputation: 3016

Hi and welcome to Stack Overflow.

One possibility is that you don't have your ViewController's File's Owner selected when you open up your Identity Inspector. Example:

enter image description here

Notice how Custom Class in Identity Inspector is blank! And I just created FirstViewController and checked the "create XIB" box. What gives? Well on the left I have the UIView selected instead of file's owner.

Now look at this:

enter image description here

This time I have file's owner selected on the left. And now on the right Custom Class in Identity Inspector says it's FirstViewController.

If you select file's owner in Interface Builder then go to the Identity Inspector there you'll find your class that you want to connect to your VC.

To see this list on the left make sure to click the button that expands this window. It's right here:

enter image description here

Upvotes: 2

Duncan C
Duncan C

Reputation: 131426

In general what you do is this:

  1. Drag an instance of your custom object's parent class into the XIB/Storyboard.
  2. Go to the identity inspector, select the "Class" entry, and type your custom class name there. It should auto-fill the class name for you.

(Note that this is an Xcode/IB question, and in no way specific to Swift.)

Upvotes: 0

Related Questions