Am getting the device local currency symbol by using this code.
NSLocale *theLocale = [NSLocale currentLocale];
NSString *symbol = [theLocale objectForKey:NSLocaleCurrencySymbol];
NSLog(@"Symbol : %@",symbol);
NSString *code = [theLocale objectForKey:NSLocaleCurrencyCode];
NSLog(@"Code : %@",code);
When the app restart the currency symbol changing but when the app from background the currency symbol not updating.
- In iPhone setting i have changed the region United States and launched the app the currency symbol show “$”.
- When i have change the region India and get the app from Background and call the same code it shows again “$”. The currency symbol not updating. When i came back and reenter into the screen the currency symbol updating to India symbol.
In appDelegate:
- (void)applicationWillEnterForeground:(UIApplication *)application:
[[NSNotificationCenter defaultCenter] postNotificationName:@"CurrencyUpdated" object:nil];
In sampleViewController: viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadCurrencySymbol) name:@"CurrencyUpdated" object:nil];
In sampleViewController:
-(void) reloadCurrencySymbol
{
NSLocale *theLocale = [NSLocale currentLocale];
NSString *symbol = [theLocale objectForKey:NSLocaleCurrencySymbol];
NSLog(@"Symbol : %@",symbol);
NSString *code = [theLocale objectForKey:NSLocaleCurrencyCode];
NSLog(@"Code : %@",code);
}
Can anyone please help to solve this issue? Thanks in advance.
EDIT
I have recalled the [self viewDidLoad]; but the region has not changed. When i return to previous screen and again enter into the same screen the region is updating. Can anyone please help to solve this? Thanks.
in your sampleview controller add this in viewdidLoad
this is the right way to reload your symbol when the app becomes active