When can Locale.current().regionCode return nil?

Hello everyone!

I'm about to develop an iOS application, that depends strongly on the value of

Locale.current().regionCode

which is an optional value. The application will be used in worldwide, and as I mentioned above, that the application depends on the value of the optional regionCode.

My question is, when would this value be nil, in which case? what is the limitation of depending on it?

Thank you,
Rashid F.

I think the regionCode simply returns the region:

Locale(identifier: "cs").regionCode // nil
Locale(identifier: "cs_CZ").regionCode // CZ

So it can be nil quite easily.

But I guess in case of using Locale.current it will never be nil? I think it's impossible in device settings to not have a region set.

1 Like