<!--
{
  "availability" : [
    "iOS: 12.2.0 -",
    "iPadOS: 12.2.0 -",
    "macCatalyst: 12.2.0 -",
    "macOS: 10.14.4 -",
    "tvOS: 12.2.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/MutableRawSpan/unsafeLoad(fromUncheckedByteOffset:as:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s14MutableRawSpanV10unsafeLoad23fromUncheckedByteOffset2asxSi_xmtlF"
  },
  "title" : "unsafeLoad(fromUncheckedByteOffset:as:)"
}
-->

# unsafeLoad(fromUncheckedByteOffset:as:)

Returns a new instance of the given type, constructed from the raw memory
at the specified offset.

```
func unsafeLoad<T>(fromUncheckedByteOffset offset: Int, as type: T.Type) -> T
```

## Parameters

`offset`

The offset from this pointer, in bytes. `offset` must be
nonnegative. The default is zero.

`type`

The type of the instance to create.

## Return Value

A new instance of type `T`, read from the raw bytes at
`offset`. The returned instance is memory-managed and unassociated
with the value in the memory referenced by this pointer.

## Discussion

The memory at this pointer plus `offset` must be properly aligned for
accessing `T` and initialized to `T` or another type that is layout
compatible with `T`.

This is an unsafe operation. This function does not validate the bounds
of the memory access, and failure to meet the preconditions
above may produce an invalid value of `T`.

---

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)