Christopher Wade Cantley Christopher Wade Cantley - 1 year ago 90
iOS Question

How to capitalize each word in a string using Swift iOS

Is there a function to capitalize each word in a string or is this a manual process?

For e.g. "bob is tall"
And I would like "Bob Is Tall"

Surely there is something and none of the Swift IOS answers I have found seemed to cover this.

Answer Source

Are you looking for capitalizedString

A string with the first character in each word changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values.

and/or capitalizedStringWithLocale(_:)

Returns a capitalized representation of the receiver using the specified locale.

For strings presented to users, pass the current locale ([NSLocale currentLocale]). To use the system locale, pass nil.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download