<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/RunLoop/run(mode:before:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRunLoop(im)runMode:beforeDate:"
  },
  "title" : "run(mode:before:)"
}
-->

# run(mode:before:)

Runs the loop once, blocking for input in the specified mode until a given date.

```
func run(mode: RunLoop.Mode, before limitDate: Date) -> Bool
```

## Parameters

`mode`

The mode in which to run. You may specify custom modes or use one of the modes listed in `Run Loop Modes`.

`limitDate`

The date until which to block.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the run loop ran and processed an input source or if the specified timeout value was reached; otherwise, <doc://com.apple.documentation/documentation/Swift/false> if the run loop could not be started.

## Discussion

If no input sources or timers are attached to the run loop, this method exits immediately and returns <doc://com.apple.documentation/documentation/Swift/false>; otherwise, it returns after either the first input source is processed or `limitDate` is reached. Manually removing all known input sources and timers from the run loop does not guarantee that the run loop will exit immediately. macOS may install and remove additional input sources as needed to process requests targeted at the receiver’s thread. Those sources could therefore prevent the run loop from exiting.

> Note:
> A timer is not considered an input source and may fire multiple times while waiting for this method to return

---

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)