If I am trying to initialize a NSLocale with a certain locale identifier, how can I tell if it is a legit identifier? No matter what identifier I pass in, even a garbage one, NSLocale still gets initialized to something.
For example, if you pass in "ar_NO", a locale with language arabic and a (invalid) country code of NO, the NSLocale object that I get seems legitimate. For example, if I call -[NSCalendar firstWeekday]
from a calendar with that locale, it will return Monday. My question, is where is that coming from? Does iOS fall back to another locale in case it cant use the given identifier? I would think it would fall back to the base "ar", but "ar" firstWeekday is Saturday, so that is not the case.
Note: I know that the identifiers are specificed by ISO BCP 47 specifications and I know about the [NSLocale availableLocaleIdentifiers]
function, but that doesnt really help me because if I use an identifier not in that list, I still get a NSLocale.
Anyone have any thoughts? Thanks in advance