diff --git a/Libraries/Image/RCTAnimatedImage.m b/Libraries/Image/RCTAnimatedImage.m index 85bf09e05d3..4b32c8bb9b8 100644 --- a/Libraries/Image/RCTAnimatedImage.m +++ b/Libraries/Image/RCTAnimatedImage.m @@ -65,7 +65,7 @@ NSMutableArray *frames = [NSMutableArray array]; for (size_t i = 0; i < frameCount; i++) { - RCTGIFCoderFrame *frame = [[RCTGIFCoderFrame alloc] init]; + RCTGIFCoderFrame *frame = [RCTGIFCoderFrame new]; frame.index = i; frame.duration = [self frameDurationAtIndex:i source:imageSource]; [frames addObject:frame]; diff --git a/Libraries/Image/RCTImageCache.m b/Libraries/Image/RCTImageCache.m index e485e806e77..4c7b598d232 100644 --- a/Libraries/Image/RCTImageCache.m +++ b/Libraries/Image/RCTImageCache.m @@ -39,7 +39,7 @@ static NSString *RCTCacheKeyForImage(NSString *imageTag, CGSize size, CGFloat sc if (self = [super init]) { _decodedImageCache = [NSCache new]; _decodedImageCache.totalCostLimit = 20 * 1024 * 1024; // 20 MB - _cacheStaleTimes = [[NSMutableDictionary alloc] init]; + _cacheStaleTimes = [NSMutableDictionary new]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clearCache) @@ -151,7 +151,7 @@ static NSString *RCTCacheKeyForImage(NSString *imageTag, CGSize size, CGFloat sc static NSDateFormatter *formatter; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - formatter = [[NSDateFormatter alloc] init]; + formatter = [NSDateFormatter new]; formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; formatter.dateFormat = @"EEE',' dd MMM yyyy HH':'mm':'ss 'GMT'"; formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; diff --git a/Libraries/Image/RCTImageView.mm b/Libraries/Image/RCTImageView.mm index 42a01adb205..60a46555378 100644 --- a/Libraries/Image/RCTImageView.mm +++ b/Libraries/Image/RCTImageView.mm @@ -87,7 +87,7 @@ static NSDictionary *onLoadParamsForSource(RCTImageSource *source) { if ((self = [super initWithFrame:CGRectZero])) { _bridge = bridge; - _imageView = [[RCTUIImageViewAnimated alloc] init]; + _imageView = [RCTUIImageViewAnimated new]; _imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self addSubview:_imageView]; diff --git a/Libraries/Image/RCTUIImageViewAnimated.m b/Libraries/Image/RCTUIImageViewAnimated.m index 4ab99406a3c..b10db4da68e 100644 --- a/Libraries/Image/RCTUIImageViewAnimated.m +++ b/Libraries/Image/RCTUIImageViewAnimated.m @@ -130,7 +130,7 @@ static NSUInteger RCTDeviceFreeMemory() { - (NSOperationQueue *)fetchQueue { if (!_fetchQueue) { - _fetchQueue = [[NSOperationQueue alloc] init]; + _fetchQueue = [NSOperationQueue new]; _fetchQueue.maxConcurrentOperationCount = 1; } return _fetchQueue; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index d75f140c9d2..865a03488d9 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -300,7 +300,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) self.backedTextInputView.inputView = nil; } else { // Hides keyboard, but keeps blinking cursor. - self.backedTextInputView.inputView = [[UIView alloc] init]; + self.backedTextInputView.inputView = [UIView new]; } } @@ -607,7 +607,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) _hasInputAccesoryView = shouldHaveInputAccesoryView; if (shouldHaveInputAccesoryView) { - UIToolbar *toolbarView = [[UIToolbar alloc] init]; + UIToolbar *toolbarView = [UIToolbar new]; [toolbarView sizeToFit]; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index 4b59899560b..74282157632 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -811,7 +811,7 @@ static UIColor *RCTColorFromSemanticColorName(NSString *semanticColorName) */ static NSString *RCTSemanticColorNames() { - NSMutableString *names = [[NSMutableString alloc] init]; + NSMutableString *names = [NSMutableString new]; NSDictionary *colorMap = RCTSemanticColorsMap(); NSArray *allKeys = [[[colorMap allKeys] mutableCopy] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; diff --git a/React/CoreModules/RCTDevMenu.mm b/React/CoreModules/RCTDevMenu.mm index 881c3f2eac1..d956be8926b 100644 --- a/React/CoreModules/RCTDevMenu.mm +++ b/React/CoreModules/RCTDevMenu.mm @@ -350,7 +350,7 @@ RCT_EXPORT_MODULE() [weakSelf setDefaultJSBundle]; return; } - NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; + NSNumberFormatter *formatter = [NSNumberFormatter new]; formatter.numberStyle = NSNumberFormatterDecimalStyle; NSNumber *portNumber = [formatter numberFromString:portTextField.text]; diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index 6d89e699307..da4fd4d2c27 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -39,7 +39,7 @@ using namespace facebook::react; static auto const defaultProps = std::make_shared(); _props = defaultProps; - _refreshControl = [[UIRefreshControl alloc] init]; + _refreshControl = [UIRefreshControl new]; [_refreshControl addTarget:self action:@selector(handleUIControlEventValueChanged) forControlEvents:UIControlEventValueChanged]; diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 082933ad6a6..d1d8cc3f2ae 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -105,7 +105,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg static const auto defaultProps = std::make_shared(); _props = defaultProps; - _childComponentViews = [[NSMutableArray alloc] init]; + _childComponentViews = [NSMutableArray new]; _scrollView = [[RCTEnhancedScrollView alloc] initWithFrame:self.bounds]; _scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 8fe5537da5c..bbe622eebfc 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -67,7 +67,7 @@ using namespace facebook::react; _props = defaultProps; auto &props = *defaultProps; - _backedTextInputView = props.traits.multiline ? [[RCTUITextView alloc] init] : [[RCTUITextField alloc] init]; + _backedTextInputView = props.traits.multiline ? [RCTUITextView new] : [RCTUITextField new]; _backedTextInputView.textInputDelegate = self; _ignoreNextTextInputCall = NO; _comingFromJS = NO; @@ -465,7 +465,7 @@ using namespace facebook::react; } if (shouldHaveInputAccesoryView) { - UIToolbar *toolbarView = [[UIToolbar alloc] init]; + UIToolbar *toolbarView = [UIToolbar new]; [toolbarView sizeToFit]; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; @@ -565,8 +565,7 @@ using namespace facebook::react; - (void)_setMultiline:(BOOL)multiline { [_backedTextInputView removeFromSuperview]; - UIView *backedTextInputView = - multiline ? [[RCTUITextView alloc] init] : [[RCTUITextField alloc] init]; + UIView *backedTextInputView = multiline ? [RCTUITextView new] : [RCTUITextField new]; backedTextInputView.frame = _backedTextInputView.frame; RCTCopyBackedTextInput(_backedTextInputView, backedTextInputView); _backedTextInputView = backedTextInputView; diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 2b9d5381adb..4c447bd4df8 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -578,7 +578,7 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle) layer.backgroundColor = _backgroundColor.CGColor; } else { if (!_borderLayer) { - _borderLayer = [[CALayer alloc] init]; + _borderLayer = [CALayer new]; _borderLayer.zPosition = -1024.0f; _borderLayer.frame = layer.bounds; _borderLayer.magnificationFilter = kCAFilterNearest; diff --git a/React/Fabric/Mounting/RCTComponentViewFactory.mm b/React/Fabric/Mounting/RCTComponentViewFactory.mm index eef565f17dc..e559426a9aa 100644 --- a/React/Fabric/Mounting/RCTComponentViewFactory.mm +++ b/React/Fabric/Mounting/RCTComponentViewFactory.mm @@ -68,7 +68,7 @@ static Class RCTComponentViewClassWithName(const char static RCTComponentViewFactory *componentViewFactory; dispatch_once(&onceToken, ^{ - componentViewFactory = [[RCTComponentViewFactory alloc] init]; + componentViewFactory = [RCTComponentViewFactory new]; [componentViewFactory registerComponentViewClass:[RCTRootComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTViewComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTParagraphComponentView class]]; @@ -183,7 +183,7 @@ static Class RCTComponentViewClassWithName(const char Class viewClass = componentViewClassDescriptor.viewClass; return RCTComponentViewDescriptor{ - .view = [[viewClass alloc] init], + .view = [viewClass new], .observesMountingTransactionWillMount = componentViewClassDescriptor.observesMountingTransactionWillMount, .observesMountingTransactionDidMount = componentViewClassDescriptor.observesMountingTransactionDidMount, }; diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index f09ae72ce41..3d1b81a3ff3 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -155,7 +155,7 @@ static void RCTPerformMountInstructions( - (instancetype)init { if (self = [super init]) { - _componentViewRegistry = [[RCTComponentViewRegistry alloc] init]; + _componentViewRegistry = [RCTComponentViewRegistry new]; } return self; diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 57b6889bc20..445f7f464f2 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -91,8 +91,8 @@ static BackgroundExecutor RCTGetBackgroundExecutor() _runtimeExecutor = runtimeExecutor; _contextContainer = contextContainer; - _surfaceRegistry = [[RCTSurfaceRegistry alloc] init]; - _mountingManager = [[RCTMountingManager alloc] init]; + _surfaceRegistry = [RCTSurfaceRegistry new]; + _mountingManager = [RCTMountingManager new]; _mountingManager.contextContainer = contextContainer; _mountingManager.delegate = self; diff --git a/React/Tests/Text/RCTParagraphComponentViewTests.mm b/React/Tests/Text/RCTParagraphComponentViewTests.mm index e847ef76f2f..0b8004edf0b 100644 --- a/React/Tests/Text/RCTParagraphComponentViewTests.mm +++ b/React/Tests/Text/RCTParagraphComponentViewTests.mm @@ -322,17 +322,17 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode( - (void)testAttributedString { ParagraphShadowNode::ConcreteState::Shared _stateA = stateWithShadowNode(ParagrahShadowNodeA_); - RCTParagraphComponentView *paragraphComponentViewA = [[RCTParagraphComponentView alloc] init]; + RCTParagraphComponentView *paragraphComponentViewA = [RCTParagraphComponentView new]; [paragraphComponentViewA updateProps:ParagrahShadowNodeA_->getProps() oldProps:nullptr]; [paragraphComponentViewA updateState:_stateA oldState:nil]; ParagraphShadowNode::ConcreteState::Shared _stateB = stateWithShadowNode(ParagrahShadowNodeB_); - RCTParagraphComponentView *paragraphComponentViewB = [[RCTParagraphComponentView alloc] init]; + RCTParagraphComponentView *paragraphComponentViewB = [RCTParagraphComponentView new]; [paragraphComponentViewB updateProps:ParagrahShadowNodeB_->getProps() oldProps:nullptr]; [paragraphComponentViewB updateState:_stateB oldState:nil]; ParagraphShadowNode::ConcreteState::Shared _stateC = stateWithShadowNode(ParagrahShadowNodeC_); - RCTParagraphComponentView *paragraphComponentViewC = [[RCTParagraphComponentView alloc] init]; + RCTParagraphComponentView *paragraphComponentViewC = [RCTParagraphComponentView new]; [paragraphComponentViewC updateProps:ParagrahShadowNodeC_->getProps() oldProps:nullptr]; [paragraphComponentViewC updateState:_stateC oldState:nil]; @@ -358,7 +358,7 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode( { // initialize the paragraphComponentView to get the accessibilityElements ParagraphShadowNode::ConcreteState::Shared _state = stateWithShadowNode(ParagrahShadowNodeA_); - RCTParagraphComponentView *paragraphComponentView = [[RCTParagraphComponentView alloc] init]; + RCTParagraphComponentView *paragraphComponentView = [RCTParagraphComponentView new]; [paragraphComponentView updateProps:ParagrahShadowNodeA_->getProps() oldProps:nullptr]; [paragraphComponentView updateState:_state oldState:nil]; @@ -379,7 +379,7 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode( - (void)testAccessibilityLinkWrappingMultipleLines { ParagraphShadowNode::ConcreteState::Shared _state = stateWithShadowNode(ParagrahShadowNodeB_); - RCTParagraphComponentView *paragraphComponentView = [[RCTParagraphComponentView alloc] init]; + RCTParagraphComponentView *paragraphComponentView = [RCTParagraphComponentView new]; [paragraphComponentView updateProps:ParagrahShadowNodeB_->getProps() oldProps:nullptr]; [paragraphComponentView updateState:_state oldState:nil]; @@ -393,7 +393,7 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode( - (void)testAccessibilityTruncatedText { ParagraphShadowNode::ConcreteState::Shared _state = stateWithShadowNode(ParagrahShadowNodeC_); - RCTParagraphComponentView *paragraphComponentView = [[RCTParagraphComponentView alloc] init]; + RCTParagraphComponentView *paragraphComponentView = [RCTParagraphComponentView new]; [paragraphComponentView updateProps:ParagrahShadowNodeC_->getProps() oldProps:nullptr]; [paragraphComponentView updateState:_state oldState:nil]; @@ -458,7 +458,7 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode( rootShadowNode->layoutIfNeeded(); ParagraphShadowNode::ConcreteState::Shared _state = stateWithShadowNode(paragrahShadowNode); - RCTParagraphComponentView *paragraphComponentView = [[RCTParagraphComponentView alloc] init]; + RCTParagraphComponentView *paragraphComponentView = [RCTParagraphComponentView new]; [paragraphComponentView updateProps:paragrahShadowNode->getProps() oldProps:nullptr]; [paragraphComponentView updateState:_state oldState:nil]; diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index e2cdef652ad..c8faede0724 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -232,8 +232,8 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : unused) return nil; } - accessibilityActionsNameMap = [[NSMutableDictionary alloc] init]; - accessibilityActionsLabelMap = [[NSMutableDictionary alloc] init]; + accessibilityActionsNameMap = [NSMutableDictionary new]; + accessibilityActionsLabelMap = [NSMutableDictionary new]; NSMutableArray *actions = [NSMutableArray array]; for (NSDictionary *action in self.accessibilityActions) { if (action[@"name"]) { diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m index 72e195c556b..bee8798edf8 100644 --- a/React/Views/RCTViewManager.m +++ b/React/Views/RCTViewManager.m @@ -189,7 +189,7 @@ RCT_CUSTOM_VIEW_PROPERTY(accessibilityRole, UIAccessibilityTraits, RCTView) RCT_CUSTOM_VIEW_PROPERTY(accessibilityState, NSDictionary, RCTView) { NSDictionary *state = json ? [RCTConvert NSDictionary:json] : nil; - NSMutableDictionary *newState = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *newState = [NSMutableDictionary new]; if (!state) { return; diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm index 11ef92858ec..c92dee1a17d 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm +++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm @@ -310,10 +310,10 @@ NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedSt static UIImage *placeholderImage; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - placeholderImage = [[UIImage alloc] init]; + placeholderImage = [UIImage new]; }); - NSMutableAttributedString *nsAttributedString = [[NSMutableAttributedString alloc] init]; + NSMutableAttributedString *nsAttributedString = [NSMutableAttributedString new]; [nsAttributedString beginEditing]; diff --git a/packages/rn-tester/RNTesterUnitTests/RCTPerformanceLoggerTests.m b/packages/rn-tester/RNTesterUnitTests/RCTPerformanceLoggerTests.m index 44b492e40a9..a0a524e6ca4 100644 --- a/packages/rn-tester/RNTesterUnitTests/RCTPerformanceLoggerTests.m +++ b/packages/rn-tester/RNTesterUnitTests/RCTPerformanceLoggerTests.m @@ -17,7 +17,7 @@ - (void)testLabelCountInSyncWithRCTPLTag { - RCTPerformanceLogger *logger = [[RCTPerformanceLogger alloc] init]; + RCTPerformanceLogger *logger = [RCTPerformanceLogger new]; XCTAssertEqual([logger labelsForTags].count, RCTPLSize); }