From 269bab73b6ad8f0e54fcd2b84f278ba857baf4af Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 1 Mar 2018 13:46:22 -0800 Subject: [PATCH] Add nil check for country code and language code (#4732) NSLocale objectForKey: may return nil for NSLocaleLanguageCode and NSLocateCountryCode in certain cases. This adds a defensive nil check for such cases. --- .../darwin/ios/framework/Source/FlutterViewController.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 44ee89abf9cd0..87682de7b3514 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -724,7 +724,8 @@ - (void)onLocaleUpdated:(NSNotification*)notification { NSLocale* currentLocale = [NSLocale currentLocale]; NSString* languageCode = [currentLocale objectForKey:NSLocaleLanguageCode]; NSString* countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; - [_localizationChannel.get() invokeMethod:@"setLocale" arguments:@[ languageCode, countryCode ]]; + if (languageCode && countryCode) + [_localizationChannel.get() invokeMethod:@"setLocale" arguments:@[ languageCode, countryCode ]]; } #pragma mark - Set user settings