---
title: "string(for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/listformatter/string(for:)"
---

# string(for:)

Creates a formatted string for an array of items.

## Declaration

```swift
func string(for obj: Any?) -> String?
```

## Parameters

- `obj`: An array of objects to format as a list.

## Return Value

Return Value A formatted string representing the list of objects in an array. Returns nil if the formatter can’t generate a description for all objects in the array, or if obj is nil.

## Discussion

Discussion The list formatter uses itemFormatter to format each item in the array. If itemFormatter doesn’t apply to a particular item, the list formatter falls back to the item’s description(withLocale:) or localizedDescription if implemented. If those methods aren’t implemented, the formatter uses description instead.

## See Also

### Converting Arrays to Formatted Lists

- [string(from:)](foundation/listformatter/string(from:).md)
- [localizedString(byJoining:)](foundation/listformatter/localizedstring(byjoining:).md)
