---
title: "scheduledTimer(withTimeInterval:repeats:block:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/timer/scheduledtimer(withtimeinterval:repeats:block:)"
---

# scheduledTimer(withTimeInterval:repeats:block:)

Creates a timer and schedules it on the current run loop in the default mode.

## Declaration

```swift
class func scheduledTimer(withTimeInterval interval: TimeInterval, repeats: Bool, block: @escaping @Sendable (Timer) -> Void) -> Timer
```

## Parameters

- `interval`: The number of seconds between firings of the timer. If interval is less than or equal to 0.0, this method chooses the nonnegative value of 0.0001 seconds instead.
- `repeats`: If true, the timer will repeatedly reschedule itself until invalidated. If false, the timer will be invalidated after it fires.
- `block`: A block to be executed when the timer fires. The block takes a single NSTimer parameter and has no return value.

## Return Value

Return Value A new NSTimer object, configured according to the specified parameters.

## Discussion

Discussion After interval seconds have elapsed, the timer fires, executing block.

## See Also

### Creating a Timer

- [scheduledTimer(timeInterval:target:selector:userInfo:repeats:)](foundation/timer/scheduledtimer(timeinterval:target:selector:userinfo:repeats:).md)
- [scheduledTimer(timeInterval:invocation:repeats:)](foundation/timer/scheduledtimer(timeinterval:invocation:repeats:).md)
- [init(timeInterval:repeats:block:)](foundation/timer/init(timeinterval:repeats:block:).md)
- [init(timeInterval:target:selector:userInfo:repeats:)](foundation/timer/init(timeinterval:target:selector:userinfo:repeats:).md)
- [init(timeInterval:invocation:repeats:)](foundation/timer/init(timeinterval:invocation:repeats:).md)
- [init(fire:interval:repeats:block:)](foundation/timer/init(fire:interval:repeats:block:).md)
- [init(fireAt:interval:target:selector:userInfo:repeats:)](foundation/timer/init(fireat:interval:target:selector:userinfo:repeats:).md)
