A capitalized representation of the string.
SDKs
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
@property(readonly, copy) NSString *capitalizedString;
Discussion
A capitalized string is 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. A word is any sequence of characters delimited by spaces, tabs, or line terminators (listed under get
). Some common word delimiting punctuation isn’t considered, so this property may not generally produce the desired results for multiword strings.
Case transformations aren’t guaranteed to be symmetrical or to produce strings of the same lengths as the originals. See lowercase
for an example.
This property performs the canonical (non-localized) mapping. It is suitable for programming operations that require stable results not depending on the current locale.
Important
When working with text that’s presented to the user, use localized
or capitalized
instead.