title: All dates between two Date objects (Swift)
body: <p>I’m creating a date using <code>NSDateComponents()</code>.</p>
  
  <pre><code>let startDate = NSDateComponents()
  startDate.year = 2015
  startDate.month = 9
  startDate.day = 1
  let calendar = NSCalendar.currentCalendar()
  let startDateNSDate = calendar.dateFromComponents(startDate)!
  </code></pre>
  
  <p>... now I want to print all dates since the <code>startDate</code> until today, <code>NSDate()</code>. I’ve already tried playing with <code>NSCalendarUnit</code>, but it only outputs the whole difference, not the single dates between.</p>
  
  <pre><code>let unit: NSCalendarUnit = [.Year, .Month, .Day, .Hour, .Minute, .Second]
  let diff = NSCalendar.currentCalendar().components(unit, fromDate: startDateNSDate, toDate: NSDate(), options: [])
  </code></pre>
  
  <p>How can I print all dates between two <code>Date</code>objects?</p>
  
  <p><strong>Edit 2019</strong></p>
  
  <p>In the meantime the naming of the classes had changed – <code>NSDate</code> is now just <code>Date</code>. <code>NSDateComponents</code> is now called <code>DateComponents</code>. <code>NSCalendar.currentCalendar()</code> is now just <code>Calendar.current</code>.</p>