10

I just upgraded Xcode to 5.0. I'm still fairly new to cocoa so I hope I'm overlooking something basic. Basically I can't get Xcode to see the custom classes that I want to use as parent classes for view controllers. Originally I wanted to create a custom class for a tableview controller but to simplify the problem I tried it with regular viewcontrollers, but that doesnt work either.

What I do:

  • Create new project: Single View Application
  • Add a cocoa class to it (File->New->File->Objective-C class. I name it MyViewController and make it a subclass of UIViewController
  • I select the default view that comes with the project template in the storyboard, and in the Identity inspector I try to select MyViewController under Custom Class

The class simply does not appear in the drop down, and I cant type it myself either. Many other threats reporting the same problem suggest closing/reopening the project and Xcode but that doesnt work either for me.

garma
  • 213
  • 1
  • 3
  • 12

4 Answers4

25

When you are in the storyboard, Interface Builder of Xcode, make sure you click on black colored bar under the view:

enter image description here

This will select the view controller (not the view) in the storyboard. Notice how the whole scene has a blue border around it. Once this is selected, you can set the class of the view controller in the Identity Inspector.

Community
  • 1
  • 1
wigging
  • 8,492
  • 12
  • 75
  • 117
11

I finally solved it. You must save your work and quit xcode. But look don't close, you have to quit xcode.

When you run xcode again, you will see your viewcontroller that you just created.

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
kordiseps
  • 391
  • 3
  • 12
9

Also, make sure your view controller type (e.g. TableViewController) in your storyboard matches your view controller super class (e.g. TableViewController). Otherwise, it won't show up in the list of classes to choose from.

ScottyB
  • 2,167
  • 1
  • 30
  • 46
0

For me, the problem was that my class extended a class from another framework, explicitly including the package name, eg:

class BaseMessageController: MessageKit.MessagesViewController

The fix was dropping the framework name:

class BaseMessageController: MessagesViewController

Might be an Apple bug.

Calin Drule
  • 2,899
  • 1
  • 15
  • 12