<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Dictionary/makeIterator()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SD12makeIteratorSD0B0Vyxq__GyF"
  },
  "title" : "makeIterator()"
}
-->

# makeIterator()

Returns an iterator over the dictionary’s key-value pairs.

```
func makeIterator() -> Dictionary<Key, Value>.Iterator
```

## Return Value

An iterator over the dictionary with elements of type
`(key: Key, value: Value)`.

## Discussion

Iterating over a dictionary yields the key-value pairs as two-element
tuples. You can decompose the tuple in a `for`-`in` loop, which calls
`makeIterator()` behind the scenes, or when calling the iterator’s
`next()` method directly.

```
let hues = ["Heliotrope": 296, "Coral": 16, "Aquamarine": 156]
for (name, hueValue) in hues {
    print("The hue of \(name) is \(hueValue).")
}
// Prints "The hue of Heliotrope is 296."
// Prints "The hue of Coral is 16."
// Prints "The hue of Aquamarine is 156."
```

---

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)