---
title: "init(timeInterval:invocation:repeats:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/timer/init(timeinterval:invocation:repeats:)"
---

# init(timeInterval:invocation:repeats:)

Initializes a timer object with the specified invocation object.

## Declaration

```swift
init(timeInterval ti: TimeInterval, invocation: NSInvocation, repeats yesOrNo: Bool)
```

## Parameters

- `ti`: The number of seconds between firings of the timer. If ti is less than or equal to 0.0, this method chooses the nonnegative value of 0.0001 seconds instead.
- `invocation`: The invocation to use when the timer fires. The timer instructs the invocation object to maintain a strong reference to its arguments.
- `yesOrNo`: If doc://com.apple.documentation/documentation/Swift/true, the timer will repeatedly reschedule itself until invalidated. If doc://com.apple.documentation/documentation/Swift/false, the timer will be invalidated after it fires.

## Return Value

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

## Discussion

Discussion You must add the new timer to a run loop, using add(_:forMode:). Then, after ti have elapsed, the timer fires, invoking invocation. (If the timer is configured to repeat, there is no need to subsequently re-add the timer to the run loop.)

## See Also

### Creating a Timer

- [scheduledTimer(withTimeInterval:repeats:block:)](foundation/timer/scheduledtimer(withtimeinterval:repeats:block:).md)
- [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(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)
