<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Distributed/DistributedTargetInvocationDecoder/decodeNextArgument()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Distributed"
    ],
    "preciseIdentifier" : "s:11Distributed0A23TargetInvocationDecoderP18decodeNextArgumentqd__yKlF"
  },
  "title" : "decodeNextArgument()"
}
-->

# decodeNextArgument()

Attempt to decode the next argument from the underlying buffers into pre-allocated storage
pointed at by ‘pointer’.

```
mutating func decodeNextArgument<Argument>() throws -> Argument
```

## Discussion

This method should throw if it has no more arguments available, if decoding the argument failed,
or, optionally, if the argument type we’re trying to decode does not match the stored type.

The result of the decoding operation must be stored into the provided ‘pointer’ rather than
returning a value. This pattern allows the runtime to use a heavily optimized, pre-allocated
buffer for all the arguments and their expected types. The ‘pointer’ passed here is a pointer
to a “slot” in that pre-allocated buffer. That buffer will then be passed to a thunk that
performs the actual distributed (local) instance method invocation.

### Serialization Requirement

Implementations of this method must ensure that the `Argument` type parameter conforms
to the types’ `SerializationRequirement`.

---

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)