I am developing an iOS app in which the user enters their mobile number. How do I get their country calling code? For example, if a user is in India, then +91 s
NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale.
NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
// get country code, e.g. ES (Spain), FR (France), etc.
NSLog(@"country code is:%@",countryCode);
NSString*lower=[countryCode lowercaseString];
NSString *path = [[NSBundle mainBundle] pathForResource:@"DiallingCodes" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
NSMutableDictionary *_dictCountry=[[NSMutableDictionary alloc]init];
NSMutableArray *_CodeArray=[[NSMutableArray alloc]init];
[_CodeArray addObject:dict];
_dictCountry = [_CodeArray objectAtIndex:0];
NSString*Country_code=[NSString stringWithFormat:@"+%@",[_dictCountry objectForKey:lower]];
contactTextField.text=Country_code;