# 7.2 Get My Groups

The `getMyGroups:failure` method returns all the groups, both public and private, the user is a member of.

**Method parameters :**

* **success** : Success block to be executed after user's groups are successfully retrieved.
* **failure** : Failure block to be executed if user's groups could not be retrieved, returns `BayunError`.

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

<pre class="language-objectivec"><code class="lang-objectivec"><strong>[[BayunCore sharedInstance] getMyGroups:^(NSArray&#x3C;Group*> *myGroups)  {
</strong>     for(Group *group in groups) {
          NSLog(@"Group Id - %@",group.groupId);
          NSLog(@"Group Name - %@",group.groupName);
          GroupType groupType = group.groupType;
     }
} failure:^(BayunErrorbayunError) {
    NSLog(@"Error getting my groups.");
}];
</code></pre>

{% endtab %}

{% tab title="Swift" %}

```swift

 BayunCore.sharedInstance().getMyGroups({ (myGroups) in
    for group in myGroups! {
      NSLog("Group Id - \(group.groupId!)")
      NSLog("Group Name - \(group.groupName!)")
      let groupType : GroupType = group.groupType
    }
  }, failure: { (bayunErrorCode) in
      NSLog("Error getting my groups.")
  })
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bayun.gitbook.io/bayuncoresdk-ios/6-groups/6.2-get-my-groups.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
