<!--
{
  "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/Optional/unsafelyUnwrapped",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SqsRi0_zrlE17unsafelyUnwrappedxvp"
  },
  "title" : "unsafelyUnwrapped"
}
-->

# unsafelyUnwrapped

The wrapped value of this instance, unwrapped without checking whether
the instance is `nil`.

```
var unsafelyUnwrapped: Wrapped { get }
```

## Discussion

The `unsafelyUnwrapped` property provides the same value as the forced
unwrap operator (postfix `!`). However, in optimized builds (`-O`), no
check is performed to ensure that the current instance actually has a
value. Accessing this property in the case of a `nil` value is a serious
programming error and could lead to undefined behavior or a runtime
error.

In debug builds (`-Onone`), the `unsafelyUnwrapped` property has the same
behavior as using the postfix `!` operator and triggers a runtime error
if the instance is `nil`.

The `unsafelyUnwrapped` property is recommended over calling the
`unsafeBitCast(_:)` function because the property is more restrictive
and because accessing the property still performs checking in debug
builds.

> Warning: This property trades safety for performance.  Use
> `unsafelyUnwrapped` only when you are confident that this instance
> will never be equal to `nil` and only after you’ve tried using the
> postfix `!` operator.

---

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)