I'm attempting to build a class's blueprint in order to display the current date as i.e. "Saturday January 14, 2017" but I'm unable to create an array of calendar components in Swift 3. Will I need to break them up into separate variables like I've done for the year below and then combine each variable into a string?
Here is what I have so far that won't compile but from reading other's code it has worked in the past:
import Foundation
class CurrentCalendarDate {
var currentDateString: String {
get{
let date = Date()
let calendar = Calendar.current
//let components = calendar.component(.year, from: date)
let componetsThatWeWant = calendar.component([.year, .day, .month], from: date)
let readableDate: String = "Today's date is: \(componetsThatWeWant.day) \(componetsThatWeWant.month), \(componetsThatWeWant.year)"
return readableDate
}
}
}