diff --git a/React/Modules/RCTI18nUtil.h b/React/Modules/RCTI18nUtil.h index b98719765..0f2287218 100644 --- a/React/Modules/RCTI18nUtil.h +++ b/React/Modules/RCTI18nUtil.h @@ -17,11 +17,12 @@ */ @interface RCTI18nUtil : NSObject ++ (instancetype)sharedInstance; + - (BOOL)isRTL; - (BOOL)isRTLAllowed; - (void)allowRTL:(BOOL)value; - (BOOL)isRTLForced; - (void)forceRTL:(BOOL)value; -+ (id)sharedInstance; @end diff --git a/React/Modules/RCTI18nUtil.m b/React/Modules/RCTI18nUtil.m index 443c99302..a3a206b23 100644 --- a/React/Modules/RCTI18nUtil.m +++ b/React/Modules/RCTI18nUtil.m @@ -13,13 +13,15 @@ @implementation RCTI18nUtil -+ (id)sharedInstance { - static RCTI18nUtil *sharedRCTI18nUtilInstance = nil; - @synchronized(self) { - if (sharedRCTI18nUtilInstance == nil) - sharedRCTI18nUtilInstance = [self new]; - } - return sharedRCTI18nUtilInstance; ++ (instancetype)sharedInstance +{ + static RCTI18nUtil *sharedInstance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [self new]; + }); + + return sharedInstance; } /**