<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/MutableRawSpan/storeBytes(of:toByteOffset:as:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s14MutableRawSpanV10storeBytes2of12toByteOffset2as_yx_Sixms0H5OrderOts15BitwiseCopyableRzs013ConvertibleToE0Rzs17FixedWidthIntegerRzlF"
  },
  "title" : "storeBytes(of:toByteOffset:as:_:)"
}
-->

# storeBytes(of:toByteOffset:as:_:)

Stores the given value’s bytes to the specified offset into
the span’s memory.

```
mutating func storeBytes<T>(of value: T, toByteOffset offset: Int, as type: T.Type, _ byteOrder: ByteOrder) where T : BitwiseCopyable, T : ConvertibleToBytes, T : FixedWidthInteger
```

## Parameters

`value`

The value to store as raw bytes.

`offset`

The offset in bytes into the span’s memory at which to begin
writing the bytes from the value.

`type`

The type of the instance to store.

`byteOrder`

The order in which the bytes will be encoded to the span.

## Discussion

The range of bytes required to store a value of type `T` starting at
byte offset `offset` must be completely within the span.
`offset` is not required to be aligned for `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)