> For the complete documentation index, see [llms.txt](https://bayun.gitbook.io/bayuncoresdk-ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bayun.gitbook.io/bayuncoresdk-ios/6-groups/7.10-remove-group-members-except-list.md).

# 7.10 Remove Group Members Except List

The `removeFromGroup:exceptList:removeCallingMember:success:failure` method is used to remove all members of the Group except the list of group members. Calling member is not removed from the group. Any existing member of the group can remove other members. The developer can choose to build stricter access-control mechanisms on top of this if desired (e.g. only the group-owner or group-admin is authorized to remove members from the group).

**Method parameters :**

* **groupId** : GroupId of the group.
* **groupMembers :**  NSArray of `GroupMember` **NOT** to be removed from the group. If the group members array is empty, all the members of the group are  removed except the calling member.
* **removeCallingMember :** Determines whether the calling member should be removed from the group or not.
* **success** : Success block to be executed after member is removed from the group.
* **failure** : Failure block to be executed if member could not be removed from the group, returns `BayunError`.

{% tabs %}
{% tab title="Objective-C" %}

```objectivec
GroupMember *groupMember = [[GroupMember alloc] initWithCompanyName:@"<companyName>" companyEmployeeId:@"<companyEmployeeId>"];
Bool removeCallingMember = false;
[[BayunCore sharedInstance] removeFromGroup:groupId exceptList:@[groupMember] removeCallingMember:removeCallingMember success:^{
     NSLog(@"Members are removed successfully");       
 } failure:^(BayunError error) {
     NSLog(@"Error removing the group members");                  
}];
```

{% endtab %}

{% tab title="Swift" %}

```swift
let groupMember : GroupMember = GroupMember(companyName:"<companyName>", companyEmployeeId: "<companyEmployeeId>")
let removeCallingMember : Bool =  false
BayunCore.sharedInstance()?.remove(fromGroup: "<groupId>", exceptList: [groupMember], removeCallingMember: removeCallingMember, success: {
  NSLog(@"Members are removed successfully")
}, failure: { (error) in
  NSLog("Error removing the group members") 
})
```

{% endtab %}
{% endtabs %}
