Contents

string(from:)

Creates a formatted string for an array of items.

Declaration

func string(from items: [Any]) -> String?

Parameters

  • items:

    An array of objects to format as a list.

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

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