B Brian Robinson Active Member Licensed User Longtime User Feb 6, 2015 #1 Hi All, I am attempting to get the country code of the device based off the ISO value. I found this bit of code: Code: Copy 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: Code: Copy 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?
Hi All, I am attempting to get the country code of the device based off the ISO value. I found this bit of code: Code: Copy 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: Code: Copy 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?
Erel B4X founder Staff member Licensed User Longtime User Feb 6, 2015 #2 Use the new inline Objective C feature. It is simpler: Code: Copy 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 Upvote 0
Use the new inline Objective C feature. It is simpler: Code: Copy 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
B Brian Robinson Active Member Licensed User Longtime User Feb 6, 2015 #3 Ahhhhh... Of course... Thanks Erel. Upvote 0