Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Custom Classes

How come for certain view controllers it wont let you add the custom class you created? For some view controllers it will list all of them and for others it wont.

4 Answers

Chris McKnight
PLUS
Chris McKnight
Courses Plus Student 11,045 Points

I have had trouble with XCode not refreshing properly as well. I have had to restart XCode in some cases. Also, make sure that you drag out the correct type of view controller. Interface Builder won't let you set the custom class of a controller to a view controller that isn't the correct subclass. In other words, you can't select a subclass of UITableViewController for a UICollectionViewController IB object.

OMG! thank you that was exactly what i needed.

Chris McKnight
Chris McKnight
Courses Plus Student 11,045 Points

Awesome. Glad to help. I have made that mistake before and after about 30 minutes realized that was my problem.

sometimes Xcode just doesnt refresh properly and doesnt see the viewcontroller you create. So either close the storyboard and reopen, and if it still doesnt show it in the drop down you can manually type in the name of the view controller.

Also, make sure you're selecting the view controller and not the view within it or an element in the view. I know that sounds rookie but I still make that mistake on occasion after almost half a year.

I've actually tried both of those suggestions before i made this post. It's actually frustrating and makes me feel like im doing something incorrectly.