---
title: "xpc_dictionary_apply(_:_:)"
framework: xpc
role: symbol
role_heading: Function
path: "xpc/xpc_dictionary_apply(_:_:)"
---

# xpc_dictionary_apply(_:_:)

Invokes the specified block for every key-value pair in the dictionary.

## Declaration

```swift
func xpc_dictionary_apply(_ xdict: xpc_object_t, _ applier: (UnsafePointer<CChar>, xpc_object_t) -> Bool) -> Bool
```

## Parameters

- `xdict`: The dictionary object which is to be examined.
- `applier`: The block which this function applies to every key/value pair in the dictionary.

## Return Value

Return Value A Boolean indicating whether iteration of the dictionary completed successfully. Iteration will only fail if the applier block returns false.

## Discussion

Discussion You should not modify a dictionary’s contents during iteration. There is no guaranteed order of iteration over dictionaries.

## See Also

### Dictionary objects

- [XPCDictionary](xpc/xpcdictionary.md)
- [xpc_dictionary_create(_:_:_:)](xpc/xpc_dictionary_create(_:_:_:).md)
- [xpc_dictionary_create_empty()](xpc/xpc_dictionary_create_empty().md)
- [xpc_dictionary_create_connection(_:_:)](xpc/xpc_dictionary_create_connection(_:_:).md)
- [xpc_dictionary_create_reply(_:)](xpc/xpc_dictionary_create_reply(_:).md)
- [xpc_dictionary_set_value(_:_:_:)](xpc/xpc_dictionary_set_value(_:_:_:).md)
- [xpc_dictionary_get_count(_:)](xpc/xpc_dictionary_get_count(_:).md)
- [xpc_dictionary_get_value(_:_:)](xpc/xpc_dictionary_get_value(_:_:).md)
- [xpc_dictionary_dup_fd(_:_:)](xpc/xpc_dictionary_dup_fd(_:_:).md)
- [xpc_dictionary_get_array(_:_:)](xpc/xpc_dictionary_get_array(_:_:).md)
- [xpc_dictionary_get_bool(_:_:)](xpc/xpc_dictionary_get_bool(_:_:).md)
- [xpc_dictionary_get_data(_:_:_:)](xpc/xpc_dictionary_get_data(_:_:_:).md)
- [xpc_dictionary_get_date(_:_:)](xpc/xpc_dictionary_get_date(_:_:).md)
- [xpc_dictionary_get_dictionary(_:_:)](xpc/xpc_dictionary_get_dictionary(_:_:).md)
- [xpc_dictionary_get_double(_:_:)](xpc/xpc_dictionary_get_double(_:_:).md)
