---
title: "nestedContainer(keyedBy:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/unkeyeddecodingcontainer/nestedcontainer(keyedby:)"
---

# nestedContainer(keyedBy:)

Decodes a nested container keyed by the given type.

## Declaration

```swift
mutating func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type) throws -> KeyedDecodingContainer<NestedKey> where NestedKey : CodingKey
```

## Parameters

- `type`: The key type to use for the container.

## Return Value

Return Value A keyed decoding container view into self.

## Discussion

Discussion note: DecodingError.typeMismatch if the encountered stored value is not a keyed container.
