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 trialAlphonso Sensley II
8,514 PointsWhy 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
3 Answers
Jeff McDivitt
23,970 PointsDid 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
8,514 Pointsimport 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
}
}
```
Jeff McDivitt
23,970 PointsWhat does the error say?
Alphonso Sensley II
8,514 Pointsthanks Jeff! it says exactly what i put in the title " "Use of undeclared type 'Contact' "
Jeff McDivitt
23,970 PointsJeff McDivitt
23,970 PointsCould you share your code?