so i am making a basic week picker, where you can pick a week number and year, and get the corresponding date from the weeks startpoint.
A basic test scenario
<weekOfYear
works in conjunction with yearForWeekOfYear
:
let calendar = NSCalendar.currentCalendar()
let components = NSDateComponents()
components.yearForWeekOfYear = 2015
components.weekOfYear = 15
print(calendar.dateFromComponents(components)!)
// 2015-04-05 22:00:00 +0000
Update for Swift 3 and later:
let calendar = Calendar.current
var components = DateComponents()
components.yearForWeekOfYear = 2015
components.weekOfYear = 15
print(calendar.date(from: components)!)