<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Int/init(_:)-2hmii",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s17FixedWidthIntegerPsEyxSgSScfc::SYNTHESIZED::s:Si"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a new integer value from the given string.

```
init?(_ description: String)
```

## Parameters

`description`

The ASCII representation of a number.

## Discussion

The string passed as `description` may begin with a plus or minus sign
character (`+` or `-`), followed by one or more numeric digits (`0-9`).

```
let x = Int("123")
// x == 123
```

If `description` is in an invalid format, or if the value it denotes in
base 10 is not representable, the result is `nil`. For example, the
following conversions result in `nil`:

```
Int(" 100")                       // Includes whitespace
Int("21-50")                      // Invalid format
Int("ff6600")                     // Characters out of bounds
Int("10000000000000000000000000") // Out of range
```

---

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)