title: Check for class existence in Swift
body: <p>I want to use NSURLQueryItem in my Swift iOS app. However, that class is only available since iOS 8, but my app should also run on iOS 7. How would I check for class existence in Swift?</p>
  
  <p>In Objective-C you would do something like:</p>
  
  <pre><code>if ([NSURLQueryItem class]) {
      // Use NSURLQueryItem class
  } else {
      // NSURLQueryItem is not available
  }
  </code></pre>
  
  <p>Related to this question is: How do you check for method or property existence of an existing class?</p>
  
  <p>There is a nice section in <a href="https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW4">https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW4</a> called <strong><em>Supporting Multiple Versions of iOS</em></strong>, which explains different techniques for Objective-C. How can these be translated to Swift?</p>