diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index c24a2d3df9d..140acda23c9 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -201,16 +201,16 @@ @interface HippyUIManager() { NSHashTable> *_componentTransactionListeners; std::mutex _renderQueueLock; - NSMutableDictionary *_viewManagers; - NSArray *_extraComponents; - - NSMutableArray> *_imageProviders; } - +/// All managed ViewManagers +@property (atomic, strong) NSMutableDictionary *viewManagers; +/// All extra components +@property (atomic, strong) NSArray *extraComponents; @end + @implementation HippyUIManager @synthesize domManager = _domManager; @@ -675,36 +675,37 @@ - (void)updateView:(nonnull NSNumber *)componentTag - (__kindof HippyViewManager *)viewManagerForViewName:(NSString *)viewName { HippyBridge *strongBridge = self.bridge; - if (!_viewManagers) { - _viewManagers = [NSMutableDictionary dictionary]; - if (_extraComponents) { - for (Class cls in _extraComponents) { + if (!self.viewManagers) { + NSMutableDictionary *viewManagers = [NSMutableDictionary dictionary]; + if (self.extraComponents) { + for (Class cls in self.extraComponents) { NSString *viewName = viewNameFromViewManagerClass(cls); - HippyAssert(![_viewManagers objectForKey:viewName], + HippyAssert(![viewManagers objectForKey:viewName], @"duplicated component %@ for class %@ and %@", viewName, NSStringFromClass(cls), - NSStringFromClass([_viewManagers objectForKey:viewName])); - [_viewManagers setObject:cls forKey:viewName]; + NSStringFromClass([viewManagers objectForKey:viewName])); + [viewManagers setObject:cls forKey:viewName]; } } NSArray *classes = HippyGetViewManagerClasses(strongBridge); NSMutableDictionary *defaultViewManagerClasses = [NSMutableDictionary dictionaryWithCapacity:[classes count]]; for (Class cls in classes) { NSString *viewName = viewNameFromViewManagerClass(cls); - if ([_viewManagers objectForKey:viewName]) { + if ([viewManagers objectForKey:viewName]) { continue; } [defaultViewManagerClasses setObject:cls forKey:viewName]; } - [_viewManagers addEntriesFromDictionary:defaultViewManagerClasses]; + [viewManagers addEntriesFromDictionary:defaultViewManagerClasses]; + self.viewManagers = viewManagers; } // Get and instantiate the class - id object = [_viewManagers objectForKey:viewName]; + id object = [self.viewManagers objectForKey:viewName]; if (object_isClass(object)) { HippyViewManager *viewManager = [object new]; viewManager.bridge = strongBridge; NSAssert([viewManager isKindOfClass:[HippyViewManager class]], @"Must be a HippyViewManager instance"); - [_viewManagers setObject:viewManager forKey:viewName]; + [self.viewManagers setObject:viewManager forKey:viewName]; object = viewManager; } return object; @@ -1125,7 +1126,7 @@ - (void)dispatchFunction:(const std::string &)functionName } - (void)registerExtraComponent:(NSArray *)extraComponents { - _extraComponents = extraComponents; + self.extraComponents = extraComponents; } diff --git a/renderer/native/ios/renderer/component/view/HippyShadowView.mm b/renderer/native/ios/renderer/component/view/HippyShadowView.mm index 17875abdf35..8f59aacd67b 100644 --- a/renderer/native/ios/renderer/component/view/HippyShadowView.mm +++ b/renderer/native/ios/renderer/component/view/HippyShadowView.mm @@ -97,7 +97,7 @@ - (instancetype)init { if ((self = [super init])) { _propagationLifecycle = NativeRenderUpdateLifecycleUninitialized; _frame = CGRectMake(0, 0, NAN, NAN); - _objectSubviews = [NSMutableArray arrayWithCapacity:8]; + _objectSubviews = [NSMutableArray array]; _confirmedLayoutDirection = hippy::Direction::Inherit; _layoutDirection = hippy::Direction::Inherit; }