<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Calendar/nextDate(after:matching:matchingPolicy:repeatedTimePolicy:direction:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation8CalendarV8nextDate5after8matching0F6Policy012repeatedTimeG09directionAA0D0VSgAK_AA0D10ComponentsVAC08MatchingG0OAC08RepeatediG0OAC15SearchDirectionOtF"
  },
  "title" : "nextDate(after:matching:matchingPolicy:repeatedTimePolicy:direction:)"
}
-->

# nextDate(after:matching:matchingPolicy:repeatedTimePolicy:direction:)

Computes the next date which matches (or most closely matches) a given set of components.

```
func nextDate(after date: Date, matching components: DateComponents, matchingPolicy: Calendar.MatchingPolicy, repeatedTimePolicy: Calendar.RepeatedTimePolicy = .first, direction: Calendar.SearchDirection = .forward) -> Date?
```

## Parameters

`date`

The starting date.

`components`

The components to search for.

`matchingPolicy`

Specifies the technique the search algorithm uses to find results. Default value is `.nextTime`.

`repeatedTimePolicy`

Specifies the behavior when multiple matches are found. Default value is `.first`.

`direction`

Specifies the direction in time to search. Default is `.forward`.

## Return Value

A `Date` representing the result of the search, or `nil` if a result could not be found.

## Discussion

The general semantics follow those of the `enumerateDates` function. To compute a sequence of results, use the `enumerateDates` function, rather than looping and calling this method with the previous loop iteration’s result.

---

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)