title: Setting multiple allowedUnits for NSDateComponenstFormatter in Swift
body: <h2>Background:</h2>
  
  <p>When formatting an NSTimeInterval using an NSDateComponentsFormatter, it's often handy to use the <code>allowedUnits</code> property to round the resulting string to a relevant time unit.</p>
  
  <p>For example, I may not be interested in getting time to the second, so setting the <code>allowedUnits</code> to minutes gets an appropriately rounded output string:</p>
  
  <pre><code>let duration: NSTimeInterval = 3665.0    // 1 hour, 1 minute and 5 seconds
  let durationFormatter = NSDateComponentsFormatter()
  
  durationFormatter.unitsStyle = .Full
  durationFormatter.zeroFormattingBehavior = .DropAll
  durationFormatter.allowedUnits = .Minute
  
  let formattedDuration = durationFormatter.stringFromTimeInterval(duration)
  </code></pre>
  
  <p><code>formattedDuration</code> will be "61 Minutes".</p>
  
  <h2>The problem:</h2>
  
  <p>How would you go about setting <code>allowedUnits</code> to <code>.Hour</code> and <code>.Minute</code> so the formatted duration would be "1 hour, 1 minute" instead?</p>
  
  <p>The <a href="https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSDateComponentsFormatter_class/index.html#//apple_ref/doc/uid/TP40015130-CH1-SW13" rel="nofollow">NSDateComponentFormatter Class Reference</a> doesn't really cover how to do this.</p>