Getting a Group List for an Owner

Users can get a list of groups that they are the owner of.

The following sample code shows how to get a list of groups that the current user is the owner of.

Swift:

  • // Get the currently logged-in user.
    let user = KiiUser.current()
    
    do{
      // Get a list of groups owned by the current user.
      let ownerGroups = try user!.ownerOfGroupsSynchronous() as! [KiiGroup]
    
      for group in ownerGroups{
        // Do something.
      }
    }catch(let error as NSError){
      // Handle the error.
      return
    }
  • // Get the currently logged-in user.
    let user = KiiUser.current()
    
    // Get a list of groups owned by the current user.
    user!.ownerOfGroups({ (user :KiiUser?, results : [Any]?, error : Error?) -> Void in
      if error != nil {
        // Handle the error.
        return
      }
    
      for group in results as! [KiiGroup] {
        // Do something.
      }
    })

Objective-C:

  • // Get the currently logged-in user.
    KiiUser* user = [KiiUser currentUser];
    
    NSError* error = nil;
    
    // Get a list of groups owned by the current user.
    NSArray* ownerGroups = [user ownerOfGroupsSynchronous:&error];
    if (error != nil) {
      // Handle the error.
      return;
    }
    
    for (KiiGroup* group in ownerGroups) {
      // Do something.
    }
  • // Get the currently logged-in user.
    KiiUser* user = [KiiUser currentUser];
    
    // Get a list of groups owned by the current user.
    [user ownerOfGroupsWithBlock:^(KiiUser *user, NSArray *results, NSError *error) {
      if (error != nil) {
        // Handle the error.
        return;
      }
    
      for (KiiGroup* group in results) {
        // Do something.
      }
    }];