<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSUUID",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUUID"
  },
  "title" : "NSUUID"
}
-->

# NSUUID

A universally unique value that can be used to identify types, interfaces, and other items.

```
class NSUUID
```

## Overview

In Swift, this object bridges to [`UUID`](/documentation/Foundation/NSUUID/UUID); use [`NSUUID`](/documentation/Foundation/NSUUID) when you need reference semantics or other Foundation-specific behavior.

UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs (Interface Identifiers), are 128-bit values. UUIDs created by `NSUUID` conform to RFC 4122 version 4 and are created with random bytes.

The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example `68753A44-4D6F-1226-9C60-0050E4C00067`. The hex representation looks, as you might expect, like a list of numerical values preceded by 0x. For example, `0xD7`, `0x36`, `0x95`, `0x0A`, `0x4D`, `0x6E`, `0x12`, `0x26`, `0x80`, `0x3A`, `0x00`, `0x50`, `0xE4`, `0xC0`, `0x00`, `0x67`. Because a UUID is expressed simply as an array of bytes, there are no endianness considerations for different platforms.

The `NSUUID` class is *not* toll-free bridged with CoreFoundation’s <doc://com.apple.documentation/documentation/CoreFoundation/CFUUID>. Use UUID strings to convert between `CFUUIDRef` and `NSUUID`, if needed. Two `NSUUID` objects are not guaranteed to be comparable by pointer value (as <doc://com.apple.documentation/documentation/CoreFoundation/CFUUID> is); use <doc://com.apple.documentation/documentation/ObjectiveC/NSObjectProtocol/isEqual(_:)> to compare two `NSUUID` instances.

> Important:
> The Swift overlay to the Foundation framework provides the ``doc://com.apple.foundation/documentation/Foundation/NSUUID/UUID`` structure, which bridges to the ``doc://com.apple.foundation/documentation/Foundation/NSUUID`` class. For more information about value types, see <doc://com.apple.documentation/documentation/Swift/working-with-foundation-types>.

## Topics

### Creating UUIDs

[`UUID`](/documentation/Foundation/NSUUID/UUID)

Create and returns a new UUID with RFC 4122 version 4 random bytes.

[`init()`](/documentation/Foundation/NSUUID/init())

Initializes a new UUID with RFC 4122 version 4 random bytes.

[`init(uuidString:)`](/documentation/Foundation/NSUUID/init(uuidString:))

Initializes a new UUID with the formatted string.

[`init(uuidBytes:)`](/documentation/Foundation/NSUUID/init(uuidBytes:))

Initializes a new UUID with the given bytes.

### Get UUID Values

[`getBytes(_:)`](/documentation/Foundation/NSUUID/getBytes(_:))

Returns the UUID as bytes.

[`uuidString`](/documentation/Foundation/NSUUID/uuidString)

The UUID as a string.



---

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)
