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!

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 Introduction to Table Views Displaying Contact Data Reconfiguring the Project

Why do I get a compiler error "Use of undeclared type 'Contact' " ?

Hello, I've been doing well in my learning about TableViews and this video has been a big help! However while following this "Reconfiguring the Project" video and while creating the contact variable of type Contact; xCode gives me a compiler error. Im correctly setting the type as optional so I can't figure out why this is happening.

Any help or suggestions will be greatly appreciated! PS I'm using Xcode 8.3.3

Jeff McDivitt
Jeff McDivitt
23,970 Points

Could you share your code?

3 Answers

Jeff McDivitt
Jeff McDivitt
23,970 Points

Did you make sure that you have it in your contacts.swift file?


struct Contact {
    let firstName: String
    let lastName: String
    let phone: String
    let email: String
    let street: String
    let city: String
    let state: String
    let zip: String
    let image: UIImage?
    var isFavorite: Bool

extension Contact {

    struct Key {
        static let firstName = "firstName"
        static let lastName = "lastName"
        static let phone = "phoneNumber"
        static let email = "email"
        static let street = "streetAddress"
        static let city = "city"
        static let state = "state"
        static let zip = "zip"
        static let image = "avatarName"

Jeff McDivitt

import UIKit

class ContactDetailController: UITableViewController {
  var contact: Contact?   

    override func viewDidLoad() {


    override func didReceiveMemoryWarning() {
        // Dispose of any resources that can be recreated.

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0



thanks Jeff! it says exactly what i put in the title " "Use of undeclared type 'Contact' "