<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/DiscreteFormatStyle/discreteInput(before:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation19DiscreteFormatStyleP13discreteInput6before0cF0QzSgAG_tF"
  },
  "title" : "discreteInput(before:)"
}
-->

# discreteInput(before:)

The next discretization boundary before the given input.

```
func discreteInput(before input: Self.FormatInput) -> Self.FormatInput?
```

## Return Value

For most `input`s, the method returns the “greatest” value “smaller” than
`input` for which the style produces a different [`FormatOutput`](/documentation/Foundation/FormatStyle/FormatOutput), or `nil`
if no such value exists. For some input values, the function may also return a value “smaller” than
`input` for which the style still produces the same [`FormatOutput`](/documentation/Foundation/FormatStyle/FormatOutput) as for
`input`.

## Discussion

Use this function to determine the next “smaller” input that warrants updating the formatted output.
The following example prints all possible outputs the format style can produce downwards starting
from the `startInput`:

```swift
var previousInput = startInput
while let nextInput = style.discreteInput(before: previousInput) {
    print(style.format(nextInput))
    previousInput = nextInput
}
```

---

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)