title: How to check if a certain method/class/API exists in Xamarin iOS?
body: <p>In <a href="http://blog.xamarin.com/ios-6-7-compatibility-tips/" rel="nofollow">iOS 6 &amp; 7 Compatibility Tips</a> it is recommended to check for a specific API like this</p>
  
  <pre><code>public static bool IsiOS7 {
    get { return UIDevice.CurrentDevice.CheckSystemVersion (7, 0); }
  }
  
  if(Util.IsiOS7) {
    //Call iOS 7 API
  } else {
    //Call iOS 6.1 or earlier API
  }
  </code></pre>
  
  <p>The same should go for iOS 8. Now I read that you should check if a certain method or class exists instead of version checking. Here <code>RespondsToSelector</code> comes in. That should be something like this</p>
  
  <pre><code>if (RespondsToSelector(new Selector("edgesForExtendedLayout")))
         EdgesForExtendedLayout = UIRectEdge.None;
  </code></pre>
  
  <p>But how would one check if a whole class exists like <code>UIAlertController</code>? There is no <code>NSClassFromString</code> like in Objective-C. I also saw something like this in Objective-C</p>
  
  <pre><code>if ([UIAlertController class]){
      // ...
  }
  </code></pre>
  
  <p>Would something like this do the trick?</p>
  
  <pre><code>Type type=Type.GetType("UIAlertController");
  if(type!=null)
  {
      // iOS 8 API
  }else{
      // iOS 7 or lower
  }
  </code></pre>
  
  <p>How would one do that in C#? Or which other ways exists to check for <code>UIAlertController</code>, <code>UISearchController</code>, ... and so on.</p>