<!--
{
  "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/Span/init(viewing:)-18wsr",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s4SpanVss15BitwiseCopyableRzlE7viewingAByxGs03RawA0V_tcs20ConvertibleFromBytesRzrlufc"
  },
  "title" : "init(viewing:)"
}
-->

# init(viewing:)

View initialized raw memory as a typed span.

```
init(viewing bytes: RawSpan) where Element : ConvertibleFromBytes
```

## Parameters

`bytes`

An existing `RawSpan`, which will define both this
`Span`’s lifetime and the memory it represents.

## Discussion

The `byteCount` of `bytes` must be a multiple of `Element`’s stride,
and the starting address of `bytes` must be well-aligned for the type
of `Element`. If either of these requirements is not met, this initializer
will trap at runtime.

---

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)