title: How do I find the beginning of the week from an NSDate?
body: <p>I'm implementing a calendar view, and I'd like it to start at the beginning of the week containing a particular date. Eg. If the target date is Monday, Feb 29, 2016, and the current calendar is set to start on Sunday, I'd like my view to start with Sunday, February 28.</p>
  
  <p>This seems like it should be straightforward:</p>
  
  <pre><code>let calendar = NSCalendar.currentCalendar()
  let firstDate = calendar.nextDateAfterDate(targetDate, 
                      matchingUnit: .Weekday,
                             value: calendar.firstWeekday,
                           options: .SearchBackwards)
  </code></pre>
  
  <p>But this fails with:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Exactly one option from the set {NSCalendarMatchPreviousTimePreservingSmallerUnits, NSCalendarMatchNextTimePreservingSmallerUnits, NSCalendarMatchNextTime} must be specified.'</p>
  </blockquote>
  
  <p>I can get basically what I want with:</p>
  
  <pre><code>let firstDate = calendar.nextDateAfterDate(firstDate, 
                      matchingUnit: .Weekday,
                             value: calendar.firstWeekday,
                          options: .MatchPreviousTimePreservingSmallerUnits)?
                      .dateByAddingTimeInterval(-7 * 84600)
  </code></pre>
  
  <p>But it seems like a bad practice, since sometimes the number of seconds in a day isn't 86400.</p>
  
  <p>Is there a better way?</p>