<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/os_activity_scope_enter",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "c:@F@os_activity_scope_enter"
  },
  "title" : "os_activity_scope_enter"
}
-->

# os_activity_scope_enter

Switches the current activity, saving the existing execution context.

```
extern void os_activity_scope_enter(os_activity_t activity, os_activity_scope_state_t state);
```

## Parameters

`activity`

An activity object.

    You can alternatively pass one of the global activity constants, such as [`OS_ACTIVITY_NONE`](/documentation/os/OS_ACTIVITY_NONE)     or [`OS_ACTIVITY_CURRENT`](/documentation/os/OS_ACTIVITY_CURRENT)    .

`state`

A pointer to a scope state struct in which to save the current execution context.

## Discussion

Allocate the struct on the stack in the function you used to call this function and call [`os_activity_scope_leave`](/documentation/os/os_activity_scope_leave) before leaving the scope that contains that struct.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)