iOS Question How to get the country Code

Brian Robinson

Active Member
Licensed User
Hi All,

I am attempting to get the country code of the device based off the ISO value.

I found this bit of code:

B4X:
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
and I have attempted to write it like this, but I am unsure how to specify the NSLocaleCountryCode value. This is what I have so far:
B4X:
Private Sub GetCountryCode As String
    Dim no As NativeObject
    Return no.Initialize("NSLocale") _
        .RunMethod("currentLocale", Null).RunMethod("objectForKey:", Array("NSLocaleCountryCode")).AsString
End Sub
Any ideas?
 
Top