From 8e3988dba2fe64bc8343e770cf17a6767514bc21 Mon Sep 17 00:00:00 2001 From: Frank Manns Date: Tue, 3 Oct 2017 19:44:19 -0400 Subject: [PATCH 1/2] Return instancetype for shared RCTI18nUtil instance --- React/Modules/RCTI18nUtil.h | 2 +- React/Modules/RCTI18nUtil.m | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/React/Modules/RCTI18nUtil.h b/React/Modules/RCTI18nUtil.h index b9871976591efc..c56053b6b7c793 100644 --- a/React/Modules/RCTI18nUtil.h +++ b/React/Modules/RCTI18nUtil.h @@ -22,6 +22,6 @@ - (void)allowRTL:(BOOL)value; - (BOOL)isRTLForced; - (void)forceRTL:(BOOL)value; -+ (id)sharedInstance; ++ (instancetype)sharedInstance; @end diff --git a/React/Modules/RCTI18nUtil.m b/React/Modules/RCTI18nUtil.m index 443c9930233d68..a3a206b2391c0b 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; } /** From e9044ac021bce9884a99c97eff1841f7531eabbe Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 3 Oct 2017 17:55:16 -0700 Subject: [PATCH 2/2] Update RCTI18nUtil.h --- React/Modules/RCTI18nUtil.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/Modules/RCTI18nUtil.h b/React/Modules/RCTI18nUtil.h index c56053b6b7c793..0f228721816164 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; -+ (instancetype)sharedInstance; @end