<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSBackgroundActivityScheduler/schedule(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBackgroundActivityScheduler(im)scheduleWithBlock:"
  },
  "title" : "schedule(_:)"
}
-->

# schedule(_:)

Begins scheduling the background activity.

```
func schedule(_ block: @escaping @Sendable (@escaping NSBackgroundActivityScheduler.CompletionHandler) -> Void)
```

## Parameters

`block`

A block of code to execute when the scheduler runs. This block will be called on a serial background queue appropriate for the level of quality of service specified. See [`qualityOfService`](/documentation/Foundation/NSBackgroundActivityScheduler/qualityOfService).

## Discussion

When your block is called, it’s passed a completion handler as an argument. Configure the block to invoke this handler, passing it a result of type [`NSBackgroundActivityScheduler.Result`](/documentation/Foundation/NSBackgroundActivityScheduler/Result) to indicate whether the activity finished ([`NSBackgroundActivityScheduler.Result.finished`](/documentation/Foundation/NSBackgroundActivityScheduler/Result/finished)) or should be deferred ([`NSBackgroundActivityScheduler.Result.deferred`](/documentation/Foundation/NSBackgroundActivityScheduler/Result/deferred)) and rescheduled for a later time. Failure to invoke the completion handler results in the activity not being rescheduled. For work that will be deferred and rescheduled, the block may optionally adjust scheduler properties, such as [`interval`](/documentation/Foundation/NSBackgroundActivityScheduler/interval) or [`tolerance`](/documentation/Foundation/NSBackgroundActivityScheduler/tolerance), before calling the completion handler. See [`Schedule Activity with scheduleWithBlock:`](/documentation/Foundation/NSBackgroundActivityScheduler#Schedule-Activity-with-scheduleWithBlock).

## See Also

[`NSBackgroundActivityScheduler.Result`](/documentation/Foundation/NSBackgroundActivityScheduler/Result)

These constants indicate whether background activity has been completed successfully or whether additional processing should be deferred until a more optimal time.



---

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)