---
title: RunLoop
framework: foundation
role: symbol
role_heading: Class
path: foundation/runloop
---

# RunLoop

The programmatic interface to objects that manage input sources.

## Declaration

```swift
class RunLoop
```

## Mentioned in

Processing URL session data task results with Combine

## Overview

Overview A RunLoop object processes input for sources, such as mouse and keyboard events from the window system and Port objects. A RunLoop object also processes Timer events. Your application neither creates nor explicitly manages RunLoop objects. The system creates a RunLoop object as needed for each Thread object, including the application’s main thread. If you need to access the current thread’s run loop, use the class method current. Note that from the perspective of RunLoop, Timer objects aren’t “input”—they’re a special type, and they don’t cause the run loop to return when they fire. warning: The RunLoop class is generally not thread-safe, and you must call its methods only within the context of the current thread. Don’t call the methods of a RunLoop object running in a different thread, which might cause unexpected results.

## Topics

### Accessing Run Loops and Modes

- [current](foundation/runloop/current.md)
- [currentMode](foundation/runloop/currentmode.md)
- [limitDate(forMode:)](foundation/runloop/limitdate(formode:).md)
- [main](foundation/runloop/main.md)
- [getCFRunLoop()](foundation/runloop/getcfrunloop().md)
- [RunLoop.Mode](foundation/runloop/mode.md)

### Managing Timers

- [add(_:forMode:)](foundation/runloop/add(_:formode:)-392ag.md)

### Managing Ports

- [add(_:forMode:)](foundation/runloop/add(_:formode:)-6z982.md)
- [remove(_:forMode:)](foundation/runloop/remove(_:formode:).md)

### Running a Loop

- [run()](foundation/runloop/run().md)
- [run(mode:before:)](foundation/runloop/run(mode:before:).md)
- [run(until:)](foundation/runloop/run(until:).md)
- [acceptInput(forMode:before:)](foundation/runloop/acceptinput(formode:before:).md)

### Scheduling and Canceling Tasks

- [perform(_:)](foundation/runloop/perform(_:).md)
- [perform(inModes:block:)](foundation/runloop/perform(inmodes:block:).md)
- [perform(_:target:argument:order:modes:)](foundation/runloop/perform(_:target:argument:order:modes:).md)
- [cancelPerform(_:target:argument:)](foundation/runloop/cancelperform(_:target:argument:).md)
- [cancelPerformSelectors(withTarget:)](foundation/runloop/cancelperformselectors(withtarget:).md)

### Scheduling Combine Publishers

- [schedule(options:_:)](foundation/runloop/schedule(options:_:).md)
- [schedule(after:tolerance:options:_:)](foundation/runloop/schedule(after:tolerance:options:_:).md)
- [schedule(after:interval:tolerance:options:_:)](foundation/runloop/schedule(after:interval:tolerance:options:_:).md)
- [minimumTolerance](foundation/runloop/minimumtolerance.md)
- [now](foundation/runloop/now.md)
- [RunLoop.SchedulerTimeType](foundation/runloop/schedulertimetype.md)
- [RunLoop.SchedulerOptions](foundation/runloop/scheduleroptions.md)

### Default Implementations

- [Scheduler Implementations](foundation/runloop/scheduler-implementations.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Scheduler](combine/scheduler.md)

## See Also

### Run Loop Scheduling

- [Timer](foundation/timer.md)
