title: Comparing class in swift
body: <p>I would like to check in swift whether an object is a member of a specific class.
  However the class is stored as property of an another object, in this case RKRequestDescriptor, a class of the RESTKit framework. RKRequestDescriptor has a property defined, which stores a class object in its objectClass property.</p>
  
  <p>So in objective-c I have something like:</p>
  
  <pre><code>  for (RKRequestDescriptor *thisDescr in self.requestDescriptors) {
      if ([thisDescr objectClass] == [obj class]) {
          ...
  </code></pre>
  
  <p>where "obj" is some arbitrary object to test against and since this is a subclass of RESTKits RKObjectManager, there is an array with requestDescriptors.</p>
  
  <p>Now I am having a hard time in swift to "translate" the above objective-c code. I tried:</p>
  
  <pre><code>     for var thisDescr:RKRequestDescriptor in self.requestDescriptors {
          if let newObj = obj as thisDescr.objectClass {
  </code></pre>
  
  <p>That doesn't work. Xcode throws errors. To begin with it doesn't "like" in-the loop ("expected condition in for statement). So it to:</p>
  
  <pre><code>    var thisDescr:RKRequestDescriptor?
      for index in 0..&lt;countElements(self.requestDescriptors) {
          thisDescr = self.requestDescriptors[index] as? RKRequestDescriptor
          if let newObj:AnyObject = obj as? thisDescr.objectClass {
  </code></pre>
  
  <p>but still no luck. It is really harder than I thought to "translate" objective c to swift :-(</p>