Hey so I'm working on this little app and I
let durationDateComponents = Calendar(identifier: Calendar.Identifier.gregorian).dateComponents([.year, .month, .day, .hour, .minute, .second], from: Date(), to: christmasDay, options: [])
What do I do here? I get that the error is pointing me to change something with the array, but what?
Thanks!
Remove options
. That's not part of dateComponents
and thus the compiler is having trouble identifying the method.
let calendar = Calendar.current // or, if you really need gregorian calendar regardless of the current calendar, `Calendar(identifier: .gregorian)`
let components = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: Date(), to: christmasDay)
If you remove options
, the method is successfully identified and therefore it is able to correctly interpret the expression.