I am trying to get the current day of the week in order to change an image based on what day it is. I am getting an error with my current code: "Bound value in a conditional binding must be of Optional type." I'm pretty new to swift and ios, so I'm not quite sure what to change.
func getDayOfWeek()->Int? {
if let todayDate = NSDate() {
let myCalendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)
let myComponents = myCalendar?.components(.WeekdayCalendarUnit, fromDate: todayDate)
let weekDay = myComponents?.weekday
return weekDay
} else {
return nil
}
}