所属するグループの一覧取得

ユーザーは、自分が所属しているグループの一覧を取得できます。

所属しているグループの一覧を取得するサンプルコードを以下に示します。

Swift:

  • // Get the currently logged-in user.
    let user = KiiUser.current()
    
    do{
      // Get a list of groups that the current user is a member of.
      let memberGroups = try user!.memberOfGroupsSynchronous() as! [KiiGroup]
    
      for group in memberGroups{
        // 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 that the current user is a member of.
    user!.memberOfGroups({ (user :KiiUser?, results : [Any]?, error : Error?) -> Void in
      if error != nil {
        // Handle the error.
        return
      }
    
      let memberGroups = results as! [KiiGroup]
    
      for group in memberGroups{
        // Do something.
      }
    })

Objective-C:

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