I\'m trying to get the dates within a given month.
My plan is to
Get the current calendar
let calendar = NSCalendar.currentCalendar()
Get the month and year date components from the current date
let components = calendar.components([.Year, .Month], fromDate: NSDate())
Get the date of the first day of the month
let startOfMonth = calendar.dateFromComponents(components)!
Get the number of days for the current month
let numberOfDays = calendar.rangeOfUnit(.Day, inUnit: .Month, forDate: startOfMonth).length
Create an array of NSDate instances for every day in the current month
let allDays = Array(0..Filter the days within a weekend
let workDays = allDays.filter{ !calendar.isDateInWeekend($0) }
Swift 3:
let calendar = Calendar.current
let components = calendar.dateComponents([.year, .month], from: Date())
let startOfMonth = calendar.date(from:components)!
let numberOfDays = calendar.range(of: .day, in: .month, for: startOfMonth)!.upperBound
let allDays = Array(0..