Reputation: 1829
When converting Swift syntax to the latest version I am getting the error:
Argument labels '(_:, fromDate:)' do not match any available overloads
At the following line:
let components = calendar.components(componentOptions, fromDate: NSDate())
For reference, here is the line in context of other constants/variables.
let calendar = NSCalendar.current
let componentOptions:NSCalendar.Unit = .weekday
let components = calendar.components(componentOptions, fromDate: NSDate())
var weekday = components.weekday
let days = ["S", "S", "M", "T", "W", "T", "F"]
What exactly is my error and how can I solve it? Seems like a simple fix, I just can't figure out.
Thanks.
UPDATE:
In the line:
let components = calendar.components(componentOptions, fromDate: NSDate())
I changed fromDate
to from
and after a series of Xcode recommended changes I got:
let components = calendar.dateComponents(componentOptions, from: NSDate() as Date)
but am now getting the error:
Cannot convert value of type 'NSCalendar.Unit' to expected argument type 'Set<Calendar.Component>'
Upvotes: 0
Views: 332
Reputation: 2488
Try these lines:
let calendar = Calendar.current
let components = calendar.dateComponents([.weekday], from: Date())
Upvotes: 1