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 Protocols in Swift Protocol Basics Why Are Protocols Useful?

ERROR: Use of undeclared type 'Date'?

When I follow the instructions as precise as I can I still get the error message "Use of undeclared type 'Date' " on line #32 and #35.

Why is this? I'm using Xcode version Version 9.2 (9C40b).

protocol FullNameable {
    var fullName: String { get }
}

struct User: FullNameable {
    var fullName: String
}

let user = User(fullName: "John Smith")

struct Friend: FullNameable {
    let firstName: String
    let middleName: String
    let lastName: String

    var fullName: String {
        return "\(firstName) \(middleName) \(lastName)"
    }
}

let friend = Friend(firstName: "Taylor", middleName: "Alison", lastName: "Swift")
friend.fullName

enum EmployeeType {
    case manager
    case traditional
}

class Employee {
    let name: String
    let address: String
    let startDate: Date
    let type: EmployeeType

    init(name: String, address: String, startDate: Date, type: EmployeeType) {
        self.name = name
        self.address = address
        self.startDate = startDate
        self.type = type
    }
}

Easy fix!

import Foundation

1 Answer