<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSSwapInt(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@F@NSSwapInt"
  },
  "title" : "NSSwapInt(_:)"
}
-->

# NSSwapInt(_:)

Swaps the bytes of a number.

```
func NSSwapInt(_ inv: UInt32) -> UInt32
```

## Discussion

Swaps the bytes of `iv` and returns the resulting value. Bytes are swapped from each low-order position to the corresponding high-order position and vice versa. For example, if the bytes of `inv` are numbered from 1 to 4, this function swaps bytes 1 and 4, and bytes 2 and 3.

## See Also

[`func NSSwapLong(UInt) -> UInt`](/documentation/Foundation/NSSwapLong(_:))

Swaps the bytes of a number.

[`func NSSwapShort(UInt16) -> UInt16`](/documentation/Foundation/NSSwapShort(_:))

Swaps the bytes of a number.

[`func NSSwapLongLong(UInt64) -> UInt64`](/documentation/Foundation/NSSwapLongLong(_:))

Swaps the bytes of a number.



---

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)