Getting the Owner of a Group

You can get the group owner with the getOwnerWith(_:) method.

Note that the KiiUser instance returned by the method only contains the ID. Execute the refresh(_:) method to get the user's latest information from Kii Cloud.

If the returned user is different from the logged-in user, available user information is limited. For more information, see User Attributes.

The following sample code shows how to get the group owner.

Swift 3:

  • do{
      // Get the owner user of the group.
      let owner = try group.getOwnerSynchronous()
    
      // Refresh the owner to retrieve the latest data from Kii Cloud.
      try owner.refreshSynchronous()
    
      // Do something.
    } catch let error as NSError {
      // Handle the error.
      return
    }
  • // Get the owner user of the group.
    group.getOwnerWith() { (group, owner, error) -> Void in
      if error != nil {
        // Handle the error.
        return
      }
    
      // Refresh the owner to retrieve the latest data from Kii Cloud.
      owner?.refresh { (user, error) -> Void in
        if (error != nil) {
          // Handle the error.
          return;
        }
    
        // Do something.
      }
    }

Objective-C:

  • NSError *error;
    
    // Get the owner user of the group.
    KiiUser *owner = [group getOwnerSynchronous:&error];
    
    if (error != nil) {
      // Handle the error.
      return;
    }
    
    // Refresh the owner to retrieve the latest data from Kii Cloud.
    [owner refreshSynchronous:&error];
    
    if (error != nil) {
      // Handle the error.
      return;
    }
    
    // Do something.
     
  • // Get the owner user of the group.
    [group getOwnerWithBlock:^(KiiGroup *group, KiiUser *owner, NSError *error) {
      if (error != nil) {
        // Handle the error.
        return;
      }
    
      [owner refreshWithBlock:^(KiiUser *user, NSError *error) {
        if (error != nil) {
          // Handle the error.
          return;
        }
    
        // Do something.
      }];
    }];