After import Foundation
, I wrote a class called ‘Employee’. One of its properties is of type Date
. My questions is: when instantiating Employee, how do I format its Date
property value? (I've tried YYYY-MM-DD, MM-DD-YYYY, and a few others, but Xcode won’t accept.)
Here's the class:
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
}
And here's an attempt to create an instance (2017-10-19 isn't accepted):
let nick = Employee(name: "Nick", address: "61", startDate: 2017-10-19, type: EmployeeType.traditional)
Many thanks,
Nick