An object representing information about linguistic, cultural, and technological conventions that bridges to
NSLocale when you need reference semantics or other Foundation-specific behavior.
- iOS 2.0+
- macOS 10.4+
- UIKit for Mac 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
You typically use a locale to format and interpret information about and according to the user’s customs and preferences.
You can initialize any number of locale instances with
init(locale using one of the locale identifiers found in the
available array. However, you usually use a locale configured to match the preferences of the current user.
current property to get the locale matching the current user's preferences. If you need to be alerted when the user does make changes to region settings, register for the
current notification. Alternatively, you can use the
autoupdating property to get a locale that automatically updates with the user's configuration settings:
You can inspect a locale by reading its properties, as listed in Getting Information About a Locale. For properties containing a code or identifier, you can then obtain a string suitable for presentation to the user with the methods listed in Getting Display Information About a Locale. For example, you can report the user's language as a string localized in that language using the autoupdating locale obtained in the previous example:
You frequently use a locale in conjunction with a formatter. For example, the
Date class has a
locale property that ensures dates are converted to strings that match the user's expectations about date formatting. By default, this property indicates the user's current locale, which is usually the behavior you want, but you can instead set it to another locale instance to obtain a different output. See Data Formatting Guide for more information about working with formatters.