Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Introduction to Table Views Displaying Contact Data Reconfiguring the Project

Alphonso Sensley II
PLUS
Alphonso Sensley II
Courses Plus Student 8,514 Points

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?

```Swift

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"
    }
Alphonso Sensley II
PLUS
Alphonso Sensley II
Courses Plus Student 8,514 Points

Jeff McDivitt

import UIKit


class ContactDetailController: UITableViewController {
  var contact: Contact?   


    override func viewDidLoad() {
        super.viewDidLoad()

           }

    override func didReceiveMemoryWarning() {
        super.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
    }


}

          ```
Alphonso Sensley II
Alphonso Sensley II
Courses Plus Student 8,514 Points

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