title: Check if a function is available in Swift?
body: <p>I would like to detect if the user has enabled Reduce Transparency. It's simple you just call the func <code>UIAccessibilityIsReduceMotionEnabled()</code> and it returns a <code>Bool</code>. But my app targets iOS 7 and 8 and this function isn't available on iOS 7.</p>
  
  <p>In Objective-C, this is how I checked to see if that function exists:<br></p>
  
  <pre><code>if (UIAccessibilityIsReduceMotionEnabled != NULL) { }
  </code></pre>
  
  <p>In Swift, I can't figure out how to check if it exists or not. According to <a href="https://stackoverflow.com/questions/24174422/check-if-a-func-exists-in-swift">this answer</a>, you can simply use optional chaining and if it's <code>nil</code> then it doesn't exist, but that is restricted to Obj-C protocols apparently. Xcode 6.1 doesn't like this:</p>
  
  <pre><code>let reduceMotionDetectionIsAvailable = UIAccessibilityIsReduceMotionEnabled?()
  </code></pre>
  
  <p>It wants you to remove the ?. And of course if you do so it will crash on iOS 7 because that function doesn't exist.</p>
  
  <p>What is the proper way to check if these types of functions exist?</p>