title: SWIFT Closure syntax - convert from Objective C
body: <p>I have the following function written in Objective C using blocks and I am trying to convert it to swift, but I am banging my head against the wall and can't get it sorted.</p>
  
  <p>Here is the code in Objective C</p>
  
  <pre><code>typedef void (^ResponseBlock) (BOOL succeeded, NSArray* data);
  
  - (void)findAllMediaFromDate:(NSDate*)createdAtDate block:(ResponseBlock)block
  {
  NSMutableArray *results = [NSMutableArray array];
  PFQuery *query = [PFQuery queryWithClassName:PARSE_MODEL_ACTIVITIES];
  [query orderByDescending:@"createdAt"];
  [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
      if (!error) {
          for (ActivityObject *object in objects) {
              if ([object.media.type isEqualToString: @"video"] || [object.media.type      isEqualToString: @"photo"]) {
                  [results addObject:object];
              }
          }
  
          block(YES, results);
      }
      else {
  
      }
  }];
  }
  </code></pre>
  
  <p>Now here is what I have in SWIFT.   It's a different function body, but the syntax I am trying is the same...</p>
  
  <pre><code>func userQuery (){   //This needs to return an array as ABOVE
      var results = [UserModel]()
      println("NM: userQuery")
      var query = UserModel.query()
      query.whereKey("objectId", equalTo:"7N0IWUffOZ")
      query.findObjectsInBackgroundWithBlock { (objects:[AnyObject]!, error:NSError!) -&gt; Void in
          if (objects != nil) {
              NSLog("yea")
              for object in objects{
                  results.append(object as UserModel)
                  //Need to return the array to the userQuery function
              }
  
          } else {
              NSLog("%@", error)
          }
  
      }
  
  }
  </code></pre>
  
  <p>```</p>