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
Use the new inline Objective C feature. It is simpler:
B4X:
Dim nativeMe As NativeObject = Me
Log(nativeMe.RunMethod("getCountryCode", Null).AsString)
End Sub
#If OBJC
- (NSString*) getCountryCode {
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
return countryCode;
}
#end if