メンバーユーザーの追加と削除
グループのメンバーとなるユーザーを追加または削除できます。
グループメンバーの追加
グループのオーナーは、addUser()
メソッドを使ってグループにメンバーを追加できます。
Swift:
-
// Instantiate a user. let user2 = KiiUser(uri: "Set the URI of an existing user here") // Add the user to the group. group.add(user2) do { // Save the group on the server. try group.saveSynchronous() } catch let error as NSError { // Handle the error. return }
-
// Instantiate a user. let user2 = KiiUser(uri: "Set the URI of an existing user here") // Add the user to the group. group.add(user2) // Save the group on the server. group.save { (group : KiiGroup?, error : Error?) -> Void in if error != nil { // Handle the error. return } }
Objective-C:
-
// Instantiate a user. KiiUser *user2 = [KiiUser userWithURI:@"Set the URI of an existing user here"]; // Add the user to the group. [group addUser:user2]; // Save the group on the server. NSError *error; [group saveSynchronous:&error]; if (error != nil) { // Handle the error. return; }
-
// Instantiate a user. KiiUser *user2 = [KiiUser userWithURI:@"Set the URI of an existing user here"]; // Add the user to the group. [group addUser:user2]; // Save the group on the server. [group saveWithBlock:^(KiiGroup *group, NSError *error) { if (error != nil) { // Handle the error. return; } }];
メンバー追加を反映させるために save(_:)
メソッドを必ず実行してください。
グループメンバーの削除
グループのオーナーは、removeUser()
メソッドを使ってグループからメンバーを削除できます。
Swift:
-
// Instantiate a user. let user2 = KiiUser(uri: "Set the URI of an existing user here") // Remove the user from the group. group.remove(user2) do { // Save the group on the server. try group.saveSynchronous() } catch let error as NSError { // Handle the error. return }
-
// Instantiate a user. let user2 = KiiUser(uri: "Set the URI of an existing user here") // Remove the user from the group. group.remove(user2) // Save the group on the server. group.save { (group : KiiGroup?, error : Error?) -> Void in if error != nil { // Handle the error. return } }
Objective-C:
-
// Instantiate a user. KiiUser *user2 = [KiiUser userWithURI:@"Set the URI of an existing user here"]; // Remove the user from the group. [group removeUser:user2]; // Save the group on the server. NSError *error; [group saveSynchronous:&error]; if (error != nil) { // Handle the error. return; }
-
// Instantiate a user. KiiUser *user2 = [KiiUser userWithURI:@"Set the URI of an existing user here"]; // Remove the user from the group. [group removeUser:user2]; // Save the group on the server. [group saveWithBlock:^(KiiGroup *group, NSError *error) { if (error != nil) { // Handle the error. return; } }];
メンバー削除を反映させるために save(_:)
メソッドを必ず実行してください。