From 0ffb14ec72494108990c182c3d228e7cc7bb6b32 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 24 Aug 2021 11:01:11 +0800 Subject: [PATCH] iOS: move bundle to DoricSingleton --- doric-iOS/Pod/Classes/DoricRegistry.m | 6 ++---- doric-iOS/Pod/Classes/DoricSingleton.h | 1 + doric-iOS/Pod/Classes/DoricSingleton.m | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doric-iOS/Pod/Classes/DoricRegistry.m b/doric-iOS/Pod/Classes/DoricRegistry.m index 06e6dfd2..a5c81bdc 100644 --- a/doric-iOS/Pod/Classes/DoricRegistry.m +++ b/doric-iOS/Pod/Classes/DoricRegistry.m @@ -58,7 +58,6 @@ @interface DoricRegistry () -@property(nonatomic, strong) NSMutableDictionary *bundles; @property(nonatomic, strong) NSMutableDictionary *plugins; @property(nonatomic, strong) NSMutableDictionary *nodes; @property(nonatomic, strong) NSMutableSet > *monitors; @@ -80,7 +79,6 @@ + (void)register:(DoricLibrary *)library { - (instancetype)initWithJSEngine:(DoricJSEngine *)jsEngine { if (self = [super init]) { _jsEngine = jsEngine; - _bundles = [NSMutableDictionary new]; _plugins = [NSMutableDictionary new]; _nodes = [NSMutableDictionary new]; _monitors = [NSMutableSet new]; @@ -130,11 +128,11 @@ - (void)innerRegister { } - (void)registerJSBundle:(NSString *)bundle withName:(NSString *)name { - self.bundles[name] = bundle; + DoricSingleton.instance.bundles[name] = bundle; } - (NSString *)acquireJSBundle:(NSString *)name { - return self.bundles[name]; + return DoricSingleton.instance.bundles[name]; } - (void)registerNativePlugin:(Class)pluginClass withName:(NSString *)name { diff --git a/doric-iOS/Pod/Classes/DoricSingleton.h b/doric-iOS/Pod/Classes/DoricSingleton.h index b48dd220..7c65bc97 100644 --- a/doric-iOS/Pod/Classes/DoricSingleton.h +++ b/doric-iOS/Pod/Classes/DoricSingleton.h @@ -26,6 +26,7 @@ @class DoricContextManager; @interface DoricSingleton : NSObject +@property(nonatomic, strong) NSMutableDictionary *bundles; @property(nonatomic, strong) NSMutableSet *libraries; @property(nonatomic, strong) NSHashTable *registries; @property(nonatomic, strong) NSMutableDictionary *envDic; diff --git a/doric-iOS/Pod/Classes/DoricSingleton.m b/doric-iOS/Pod/Classes/DoricSingleton.m index 2cca63d0..9c4575dd 100644 --- a/doric-iOS/Pod/Classes/DoricSingleton.m +++ b/doric-iOS/Pod/Classes/DoricSingleton.m @@ -37,6 +37,7 @@ - (instancetype)init { _storageCaches = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsCopyIn valueOptions:NSPointerFunctionsWeakMemory capacity:0]; + _bundles = [NSMutableDictionary new]; } return self; }