---
title: IntegerParseStrategy
framework: foundation
role: symbol
role_heading: Structure
path: foundation/integerparsestrategy
---

# IntegerParseStrategy

A parse strategy for creating integer values from formatted strings.

## Declaration

```swift
struct IntegerParseStrategy<Format> where Format : FormatStyle, Format.FormatInput : BinaryInteger
```

## Overview

Overview Create an explicit IntegerParseStrategy to parse multiple strings according to the same parse strategy. In the following example, usCurrencyStrategy is an IntegerParseStrategy that uses US dollars and the en_US locale’s conventions for number formatting. The example then uses this strategy to parse an array of strings, some of which represent valid US currency values. let usCurrencyStrategy: IntegerParseStrategy =     IntegerFormatStyle<Int>.Currency(code: "USD",                                      locale: Locale(identifier: "en_US"))     .parseStrategy let currencyValues = ["$100", "$1,000", "$10,000", "€100"] let parsedValues = currencyValues.map { try? usCurrencyStrategy.parse($0) } // [Optional(100), Optional(1000), Optional(10000), nil] You don’t need to instantiate a parse strategy variable to parse a single string. Instead, use the BinaryInteger initializers that take a source String and a format parameter to parse the string according to the provided FormatStyle. The following example parses a string that represents a currency value in US dollars. let formattedUSDollars = "$1,234" let parsedUSDollars = try? Int(formattedUSDollars, format: .currency(code: "USD")     .locale(Locale(identifier: "en_US"))) // 1234

## Topics

### Creating an integer parse strategy

- [init(format:lenient:)](foundation/integerparsestrategy/init(format:lenient:)-124xn.md)
- [init(format:lenient:)](foundation/integerparsestrategy/init(format:lenient:)-7tox3.md)
- [init(format:lenient:)](foundation/integerparsestrategy/init(format:lenient:)-3gbvo.md)

### Parsing strings

- [parse(_:)](foundation/integerparsestrategy/parse(_:).md)

### Accessing strategy properties

- [formatStyle](foundation/integerparsestrategy/formatstyle.md)
- [lenient](foundation/integerparsestrategy/lenient.md)

### Default Implementations

- [ParseStrategy Implementations](foundation/integerparsestrategy/parsestrategy-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [ParseStrategy](foundation/parsestrategy.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Data parsing in Swift

- [ParseableFormatStyle](foundation/parseableformatstyle.md)
- [ParseStrategy](foundation/parsestrategy.md)
- [FloatingPointParseStrategy](foundation/floatingpointparsestrategy.md)
- [Decimal.ParseStrategy](foundation/decimal/parsestrategy.md)
