<!--
{
  "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/add(_:forMode:)-392ag",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRunLoop(im)addTimer:forMode:"
  },
  "title" : "add(_:forMode:)"
}
-->

# add(_:forMode:)

Registers a given timer with a given input mode.

```
func add(_ timer: Timer, forMode mode: RunLoop.Mode)
```

## Parameters

`timer`

The timer to register with the receiver.

`mode`

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

## Discussion

You can add a timer to multiple input modes. While running in the designated mode, the receiver causes the timer to fire on or after its scheduled fire date. Upon firing, the timer invokes its associated handler routine, which is a selector on a designated object.

The receiver retains `aTimer`. To remove a timer from all run loop modes on which it is installed, send an [`invalidate()`](/documentation/Foundation/Timer/invalidate()) message to the timer.

---

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)