---
title: "personNameComponents(from:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/personnamecomponentsformatter/personnamecomponents(from:)"
---

# personNameComponents(from:)

Returns a person name components object from a given string.

## Declaration

```swift
func personNameComponents(from string: String) -> PersonNameComponents?
```

## Parameters

- `string`: A string that is parsed to create a person name components object.

## Return Value

Return Value An NSPersonNameComponents object parsing string using the receiver’s format, or nil if no components could be parsed.

## Discussion

Discussion This method uses a combination of locale rules and heuristics to determine the most likely name components for a particular string representation. Parsing name components from a representation created for an existing name components object may not produce equivalent results. important: Currently, only names using Latin or CJK scripts are supported. Here are some general rules that describe the name component parsing behavior: Names in Latin script have components delimited by whitespace. Names with a single delimited component are parsed into their most likely name component. Names in Latin script with more than two delimited components may include middle components in the givenName, middleName, or familyName name components. Names in Latin script that are inverted may be parsed into components in a different order than they appear; names in CJK script that are inverted will not typically produce the correct results. Names in Latin script may use a comma to indicate name inversion. Names in Latin script have capitalization preserved between string representation and parsed components. Text between parentheses or brackets, as well as extraneous characters in names is ignored.  |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |   |  |  |  |  |

## See Also

### Converting Between Person Name Components and Strings

- [localizedString(from:style:options:)](foundation/personnamecomponentsformatter/localizedstring(from:style:options:).md)
- [string(from:)](foundation/personnamecomponentsformatter/string(from:).md)
- [annotatedString(from:)](foundation/personnamecomponentsformatter/annotatedstring(from:).md)
- [getObjectValue(_:for:errorDescription:)](foundation/personnamecomponentsformatter/getobjectvalue(_:for:errordescription:).md)
