[Solved] How can I set the day of the week as a variable in Swift? [closed]


Assuming you need the name of the current weekday in the current locale:

let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale.currentLocale()
let today = NSDate()
let calendar = NSCalendar.currentCalendar()
let todayComponents = calendar.components(.CalendarUnitWeekday, fromDate: today)
let weekDayIdx = todayComponents.weekday
let weekday = dateFormatter.weekdaySymbols[weekDayIdx] as! String
println(weekday) // "Wednesday"

solved How can I set the day of the week as a variable in Swift? [closed]