<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Distributed/DistributedActor/init(from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Distributed"
    ],
    "preciseIdentifier" : "s:11Distributed0A5ActorPAASe2IDRpzrlE4fromxs7Decoder_p_tKcfc"
  },
  "title" : "init(from:)"
}
-->

# init(from:)

Initializes an instance of this distributed actor by decoding its [`id`](/documentation/Distributed/DistributedActor/id),
and passing it to the `DistributedActorSystem` obtained from `decoder.userInfo[actorSystemKey]`.

```
nonisolated init(from decoder: any Decoder) throws
```

## Parameters

`decoder`

used to decode the [`id`](/documentation/Distributed/DistributedActor/id) of this distributed actor.

## Requires: The decoder must have the `CodingUserInfoKey.actorSystemKey` set to

the [`ActorSystem`](/documentation/Distributed/DistributedActor/ActorSystem-swift.associatedtype) that this actor expects, as it will be used to call [`resolve(id:using:)`](/documentation/Distributed/DistributedActor/resolve(id:using:))
on, in order to obtain the instance this initializer should return.

> Throws: If the actor system value in `decoder.userInfo` is missing or mistyped;
> the `ID` fails to decode from the passed `decoder`;

---

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)