diff --git a/Examples/SampleApp/iOS/SampleApp/AppDelegate.m b/Examples/SampleApp/iOS/SampleApp/AppDelegate.m index 7e8d5fecf..762a35439 100644 --- a/Examples/SampleApp/iOS/SampleApp/AppDelegate.m +++ b/Examples/SampleApp/iOS/SampleApp/AppDelegate.m @@ -50,7 +50,7 @@ launchOptions:launchOptions]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [[UIViewController alloc] init]; + UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; diff --git a/Examples/UIExplorer/UIExplorer/AppDelegate.m b/Examples/UIExplorer/UIExplorer/AppDelegate.m index 5a3a7d87d..f394c9903 100644 --- a/Examples/UIExplorer/UIExplorer/AppDelegate.m +++ b/Examples/UIExplorer/UIExplorer/AppDelegate.m @@ -34,7 +34,7 @@ initialProperties:nil]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [[UIViewController alloc] init]; + UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m b/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m index c7d30539f..923f32caa 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m @@ -45,11 +45,11 @@ { [super setUp]; - _uiManager = [[RCTUIManager alloc] init]; + _uiManager = [RCTUIManager new]; // Register 20 views to use in the tests for (NSInteger i = 1; i <= 20; i++) { - UIView *registeredView = [[UIView alloc] init]; + UIView *registeredView = [UIView new]; [registeredView setReactTag:@(i)]; _uiManager.viewRegistry[i] = registeredView; } diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m index b17fd3ddc..670530114 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m @@ -94,7 +94,7 @@ RCT_EXPORT_METHOD(test:(__unused NSString *)a - (void)testModulesAreInvalidated { - AllocationTestModule *module = [[AllocationTestModule alloc] init]; + AllocationTestModule *module = [AllocationTestModule new]; @autoreleasepool { RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil moduleProvider:^{ @@ -113,7 +113,7 @@ RCT_EXPORT_METHOD(test:(__unused NSString *)a { __weak AllocationTestModule *weakModule; @autoreleasepool { - AllocationTestModule *module = [[AllocationTestModule alloc] init]; + AllocationTestModule *module = [AllocationTestModule new]; RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil moduleProvider:^{ return @[module]; diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTCacheTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTCacheTests.m index 30313d23b..b6bc22188 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTCacheTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTCacheTests.m @@ -37,7 +37,7 @@ - (void)setUp { - self.cache = [[RCTCache alloc] init]; + self.cache = [RCTCache new]; self.cache.countLimit = 3; self.cache.totalCostLimit = 100; } diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTContextExecutorTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTContextExecutorTests.m index f7db2d46f..fa48fcfbf 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTContextExecutorTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTContextExecutorTests.m @@ -33,7 +33,7 @@ - (void)setUp { [super setUp]; - _executor = [[RCTContextExecutor alloc] init]; + _executor = [RCTContextExecutor new]; [_executor setUp]; } @@ -129,7 +129,7 @@ static uint64_t _get_time_nanoseconds(void) "; [_executor executeApplicationScript:script sourceURL:[NSURL URLWithString:@"http://localhost:8081/"] onComplete:^(__unused NSError *error) { - NSMutableArray *params = [[NSMutableArray alloc] init]; + NSMutableArray *params = [NSMutableArray new]; id data = @1; for (int i = 0; i < 4; i++) { double samples[runs / frequency]; diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTEventDispatcherTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTEventDispatcherTests.m index 96e6bd45c..bfa52b94f 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTEventDispatcherTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTEventDispatcherTests.m @@ -61,7 +61,7 @@ [super setUp]; _bridge = [OCMockObject mockForClass:[RCTBridge class]]; - _eventDispatcher = [[RCTEventDispatcher alloc] init]; + _eventDispatcher = [RCTEventDispatcher new]; ((id)_eventDispatcher).bridge = _bridge; _eventName = RCTNormalizeInputEventName(@"sampleEvent"); diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m index 5e74bf7c4..ceb58b972 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m @@ -67,7 +67,7 @@ extern BOOL RCTIsGzippedData(NSData *data); @"headers": @{@"Content-Encoding": @"gzip"}, }; - RCTNetworking *networker = [[RCTNetworking alloc] init]; + RCTNetworking *networker = [RCTNetworking new]; __block NSURLRequest *request = nil; [networker buildRequest:query completionBlock:^(NSURLRequest *_request) { request = _request; diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTShadowViewTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTShadowViewTests.m index f396131d5..9bdda8a8d 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTShadowViewTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTShadowViewTests.m @@ -99,7 +99,7 @@ - (RCTShadowView *)_shadowViewWithStyle:(void(^)(css_style_t *style))styleBlock { - RCTShadowView *shadowView = [[RCTShadowView alloc] init]; + RCTShadowView *shadowView = [RCTShadowView new]; css_style_t style = shadowView.cssNode->style; styleBlock(&style); diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTSparseArrayTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTSparseArrayTests.m index cee52d036..57e7a0bf2 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTSparseArrayTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTSparseArrayTests.m @@ -25,13 +25,13 @@ - (void)testDictionary { - id myView = [[UIView alloc] init]; + id myView = [UIView new]; myView.reactTag = @4; - id myOtherView = [[UIView alloc] init]; + id myOtherView = [UIView new]; myOtherView.reactTag = @5; - RCTSparseArray *registry = [[RCTSparseArray alloc] init]; + RCTSparseArray *registry = [RCTSparseArray new]; XCTAssertNil(registry[@4], @"how did you have a view when none are registered?"); XCTAssertNil(registry[@5], @"how did you have a view when none are registered?"); diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m index b587d9bca..a4cf3150c 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m @@ -44,11 +44,11 @@ { [super setUp]; - _uiManager = [[RCTUIManager alloc] init]; + _uiManager = [RCTUIManager new]; // Register 20 views to use in the tests for (NSInteger i = 1; i <= 20; i++) { - UIView *registeredView = [[UIView alloc] init]; + UIView *registeredView = [UIView new]; [registeredView setReactTag:@(i)]; _uiManager.viewRegistry[i] = registeredView; } diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m index 56df9f38d..22abba34e 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -27,7 +27,7 @@ RCT_EXPORT_MODULE() - (instancetype)init { if ((self = [super init])) { - _callbacks = [[NSMutableDictionary alloc] init]; + _callbacks = [NSMutableDictionary new]; } return self; } @@ -41,7 +41,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options failureCallback:(__unused RCTResponseSenderBlock)failureCallback successCallback:(RCTResponseSenderBlock)successCallback) { - UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; + UIActionSheet *actionSheet = [UIActionSheet new]; actionSheet.title = options[@"title"]; diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index 0fe5fed75..8efd16787 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -115,11 +115,11 @@ RCT_EXPORT_MODULE() { if ((self = [super init])) { - _locationManager = [[CLLocationManager alloc] init]; + _locationManager = [CLLocationManager new]; _locationManager.distanceFilter = RCT_DEFAULT_LOCATION_ACCURACY; _locationManager.delegate = self; - _pendingRequests = [[NSMutableArray alloc] init]; + _pendingRequests = [NSMutableArray new]; } return self; } @@ -231,7 +231,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options } // Create request - RCTLocationRequest *request = [[RCTLocationRequest alloc] init]; + RCTLocationRequest *request = [RCTLocationRequest new]; request.successBlock = successBlock; request.errorBlock = errorBlock ?: ^(NSArray *args){}; request.options = options; diff --git a/Libraries/Image/RCTCameraRollManager.m b/Libraries/Image/RCTCameraRollManager.m index d28198ac0..afe4d7284 100644 --- a/Libraries/Image/RCTCameraRollManager.m +++ b/Libraries/Image/RCTCameraRollManager.m @@ -94,7 +94,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params BOOL __block foundAfter = NO; BOOL __block hasNextPage = NO; BOOL __block calledCallback = NO; - NSMutableArray *assets = [[NSMutableArray alloc] init]; + NSMutableArray *assets = [NSMutableArray new]; [_bridge.assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:^(ALAssetsGroup *group, BOOL *stopGroups) { if (group && (groupName == nil || [groupName isEqualToString:[group valueForProperty:ALAssetsGroupPropertyName]])) { diff --git a/Libraries/Image/RCTImageDownloader.m b/Libraries/Image/RCTImageDownloader.m index 6213431e2..22bbe9031 100644 --- a/Libraries/Image/RCTImageDownloader.m +++ b/Libraries/Image/RCTImageDownloader.m @@ -30,7 +30,7 @@ RCT_EXPORT_MODULE() static RCTImageDownloader *sharedInstance; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - sharedInstance = [[RCTImageDownloader alloc] init]; + sharedInstance = [RCTImageDownloader new]; }); return sharedInstance; } diff --git a/Libraries/Image/RCTImageLoader.m b/Libraries/Image/RCTImageLoader.m index dc0fbf640..575842c46 100644 --- a/Libraries/Image/RCTImageLoader.m +++ b/Libraries/Image/RCTImageLoader.m @@ -114,7 +114,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation, - (ALAssetsLibrary *)assetsLibrary { if (!_assetsLibrary) { - _assetsLibrary = [[ALAssetsLibrary alloc] init]; + _assetsLibrary = [ALAssetsLibrary new]; } return _assetsLibrary; } @@ -181,7 +181,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation, PHAsset *asset = [results firstObject]; - PHImageRequestOptions *imageOptions = [[PHImageRequestOptions alloc] init]; + PHImageRequestOptions *imageOptions = [PHImageRequestOptions new]; BOOL useMaximumSize = CGSizeEqualToSize(size, CGSizeZero); CGSize targetSize; diff --git a/Libraries/Image/RCTImagePickerManager.m b/Libraries/Image/RCTImagePickerManager.m index 7fad953b0..107f399b6 100644 --- a/Libraries/Image/RCTImagePickerManager.m +++ b/Libraries/Image/RCTImagePickerManager.m @@ -31,9 +31,9 @@ RCT_EXPORT_MODULE(ImagePickerIOS); - (instancetype)init { if ((self = [super init])) { - _pickers = [[NSMutableArray alloc] init]; - _pickerCallbacks = [[NSMutableArray alloc] init]; - _pickerCancelCallbacks = [[NSMutableArray alloc] init]; + _pickers = [NSMutableArray new]; + _pickerCallbacks = [NSMutableArray new]; + _pickerCancelCallbacks = [NSMutableArray new]; } return self; } @@ -56,7 +56,7 @@ RCT_EXPORT_METHOD(openCameraDialog:(NSDictionary *)config UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIViewController *rootViewController = keyWindow.rootViewController; - UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + UIImagePickerController *imagePicker = [UIImagePickerController new]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; @@ -78,11 +78,11 @@ RCT_EXPORT_METHOD(openSelectDialog:(NSDictionary *)config UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIViewController *rootViewController = keyWindow.rootViewController; - UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + UIImagePickerController *imagePicker = [UIImagePickerController new]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; - NSMutableArray *allowedTypes = [[NSMutableArray alloc] init]; + NSMutableArray *allowedTypes = [NSMutableArray new]; if ([config[@"showImages"] boolValue]) { [allowedTypes addObject:(NSString *)kUTTypeImage]; } diff --git a/Libraries/Image/RCTImageStoreManager.m b/Libraries/Image/RCTImageStoreManager.m index e751466f9..2193dd01f 100644 --- a/Libraries/Image/RCTImageStoreManager.m +++ b/Libraries/Image/RCTImageStoreManager.m @@ -26,7 +26,7 @@ RCT_EXPORT_MODULE() if ((self = [super init])) { // TODO: need a way to clear this store - _store = [[NSMutableDictionary alloc] init]; + _store = [NSMutableDictionary new]; } return self; } diff --git a/Libraries/Network/RCTDownloadTask.m b/Libraries/Network/RCTDownloadTask.m index 5b065675f..f86b4b990 100644 --- a/Libraries/Network/RCTDownloadTask.m +++ b/Libraries/Network/RCTDownloadTask.m @@ -101,7 +101,7 @@ RCT_NOT_IMPLEMENTED(-init) { if ([self validateRequestToken:requestToken]) { if (!_data) { - _data = [[NSMutableData alloc] init]; + _data = [NSMutableData new]; } [_data appendData:data]; if (_incrementalDataBlock) { diff --git a/Libraries/Network/RCTHTTPRequestHandler.m b/Libraries/Network/RCTHTTPRequestHandler.m index d5ee89a45..37165cfff 100644 --- a/Libraries/Network/RCTHTTPRequestHandler.m +++ b/Libraries/Network/RCTHTTPRequestHandler.m @@ -55,7 +55,7 @@ RCT_EXPORT_MODULE() { // Lazy setup if (!_session && [self isValid]) { - NSOperationQueue *callbackQueue = [[NSOperationQueue alloc] init]; + NSOperationQueue *callbackQueue = [NSOperationQueue new]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; _session = [NSURLSession sessionWithConfiguration:configuration delegate:self diff --git a/Libraries/Network/RCTNetworking.m b/Libraries/Network/RCTNetworking.m index a2f0475e2..cbd8ebbfc 100644 --- a/Libraries/Network/RCTNetworking.m +++ b/Libraries/Network/RCTNetworking.m @@ -65,7 +65,7 @@ static NSString *RCTGenerateFormBoundary() parts = [formData mutableCopy]; _callback = callback; - multipartBody = [[NSMutableData alloc] init]; + multipartBody = [NSMutableData new]; boundary = RCTGenerateFormBoundary(); return [_networker processDataForHTTPQuery:parts[0] callback:^(NSError *error, NSDictionary *result) { @@ -132,7 +132,7 @@ RCT_EXPORT_MODULE() - (instancetype)init { if ((self = [super init])) { - _tasksByRequestID = [[NSMutableDictionary alloc] init]; + _tasksByRequestID = [NSMutableDictionary new]; } return self; } @@ -248,7 +248,7 @@ RCT_EXPORT_MODULE() } NSDictionaryArray *formData = [RCTConvert NSDictionaryArray:query[@"formData"]]; if (formData) { - RCTHTTPFormDataHelper *formDataHelper = [[RCTHTTPFormDataHelper alloc] init]; + RCTHTTPFormDataHelper *formDataHelper = [RCTHTTPFormDataHelper new]; formDataHelper.networker = self; return [formDataHelper process:formData callback:callback]; } diff --git a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m index ac683fc2a..3f187b171 100644 --- a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m +++ b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m @@ -32,7 +32,7 @@ NSString *const RCTRemoteNotificationsRegistered = @"RemoteNotificationsRegister + (UILocalNotification *)UILocalNotification:(id)json { NSDictionary *details = [self NSDictionary:json]; - UILocalNotification *notification = [[UILocalNotification alloc] init]; + UILocalNotification *notification = [UILocalNotification new]; notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]] ?: [NSDate date]; notification.alertBody = [RCTConvert NSString:details[@"alertBody"]]; return notification; @@ -186,7 +186,7 @@ RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback) } - NSMutableDictionary *permissions = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *permissions = [NSMutableDictionary new]; permissions[@"alert"] = @((types & UIUserNotificationTypeAlert) > 0); permissions[@"badge"] = @((types & UIUserNotificationTypeBadge) > 0); permissions[@"sound"] = @((types & UIUserNotificationTypeSound) > 0); diff --git a/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m b/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m index 7d12736d1..7d7d32947 100644 --- a/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m +++ b/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m @@ -51,7 +51,7 @@ typedef struct RGBAPixel { { if ((self = [super init])) { _testName = [testName copy]; - _fileManager = [[NSFileManager alloc] init]; + _fileManager = [NSFileManager new]; } return self; } diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index d0326112f..63a82a0ea 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -98,7 +98,7 @@ RCT_NOT_IMPLEMENTED(-init) testModule.view = rootView; UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController; - vc.view = [[UIView alloc] init]; + vc.view = [UIView new]; [vc.view addSubview:rootView]; // Add as subview so it doesn't get resized NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; diff --git a/Libraries/Text/RCTRawTextManager.m b/Libraries/Text/RCTRawTextManager.m index beb716f75..460b127ba 100644 --- a/Libraries/Text/RCTRawTextManager.m +++ b/Libraries/Text/RCTRawTextManager.m @@ -17,7 +17,7 @@ RCT_EXPORT_MODULE() - (RCTShadowView *)shadowView { - return [[RCTShadowRawText alloc] init]; + return [RCTShadowRawText new]; } RCT_EXPORT_SHADOW_PROPERTY(text, NSString) diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index 61f1373c1..49cc35901 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -111,12 +111,12 @@ static css_dim_t RCTMeasure(void *context, float width) return _cachedTextStorage; } - NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; + NSLayoutManager *layoutManager = [NSLayoutManager new]; NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedString]; [textStorage addLayoutManager:layoutManager]; - NSTextContainer *textContainer = [[NSTextContainer alloc] init]; + NSTextContainer *textContainer = [NSTextContainer new]; textContainer.lineFragmentPadding = 0.0; textContainer.lineBreakMode = _numberOfLines > 0 ? NSLineBreakByTruncatingTail : NSLineBreakByClipping; textContainer.maximumNumberOfLines = _numberOfLines; @@ -183,7 +183,7 @@ static css_dim_t RCTMeasure(void *context, float width) _effectiveLetterSpacing = letterSpacing.doubleValue; - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; + NSMutableAttributedString *attributedString = [NSMutableAttributedString new]; for (RCTShadowView *child in [self reactSubviews]) { if ([child isKindOfClass:[RCTShadowText class]]) { RCTShadowText *shadowText = (RCTShadowText *)child; @@ -265,7 +265,7 @@ static css_dim_t RCTMeasure(void *context, float width) // if we found anything, set it :D if (hasParagraphStyle) { - NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; paragraphStyle.alignment = _textAlign; paragraphStyle.baseWritingDirection = _writingDirection; CGFloat lineHeight = round(_lineHeight * self.fontSizeMultiplier); diff --git a/Libraries/Text/RCTText.m b/Libraries/Text/RCTText.m index 162e16f70..ae244c574 100644 --- a/Libraries/Text/RCTText.m +++ b/Libraries/Text/RCTText.m @@ -23,7 +23,7 @@ - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { - _textStorage = [[NSTextStorage alloc] init]; + _textStorage = [NSTextStorage new]; _reactSubviews = [NSMutableArray array]; self.isAccessibilityElement = YES; diff --git a/Libraries/Text/RCTTextField.m b/Libraries/Text/RCTTextField.m index 261c0cdb2..a99771153 100644 --- a/Libraries/Text/RCTTextField.m +++ b/Libraries/Text/RCTTextField.m @@ -31,7 +31,7 @@ [self addTarget:self action:@selector(textFieldBeginEditing) forControlEvents:UIControlEventEditingDidBegin]; [self addTarget:self action:@selector(textFieldEndEditing) forControlEvents:UIControlEventEditingDidEnd]; [self addTarget:self action:@selector(textFieldSubmitEditing) forControlEvents:UIControlEventEditingDidEndOnExit]; - _reactSubviews = [[NSMutableArray alloc] init]; + _reactSubviews = [NSMutableArray new]; } return self; } diff --git a/Libraries/Text/RCTTextManager.m b/Libraries/Text/RCTTextManager.m index 06d52088a..92d9eb498 100644 --- a/Libraries/Text/RCTTextManager.m +++ b/Libraries/Text/RCTTextManager.m @@ -25,12 +25,12 @@ RCT_EXPORT_MODULE() - (UIView *)view { - return [[RCTText alloc] init]; + return [RCTText new]; } - (RCTShadowView *)shadowView { - return [[RCTShadowText alloc] init]; + return [RCTShadowText new]; } #pragma mark - Shadow properties diff --git a/Libraries/WebSocket/RCTSRWebSocket.m b/Libraries/WebSocket/RCTSRWebSocket.m index b65a847ee..2b6f63523 100644 --- a/Libraries/WebSocket/RCTSRWebSocket.m +++ b/Libraries/WebSocket/RCTSRWebSocket.m @@ -297,16 +297,16 @@ RCT_NOT_IMPLEMENTED(-init) _delegateDispatchQueue = dispatch_get_main_queue(); - _readBuffer = [[NSMutableData alloc] init]; - _outputBuffer = [[NSMutableData alloc] init]; + _readBuffer = [NSMutableData new]; + _outputBuffer = [NSMutableData new]; - _currentFrameData = [[NSMutableData alloc] init]; + _currentFrameData = [NSMutableData new]; - _consumers = [[NSMutableArray alloc] init]; + _consumers = [NSMutableArray new]; - _consumerPool = [[RCTSRIOConsumerPool alloc] init]; + _consumerPool = [RCTSRIOConsumerPool new]; - _scheduledRunloops = [[NSMutableSet alloc] init]; + _scheduledRunloops = [NSMutableSet new]; [self _initializeStreams]; @@ -506,7 +506,7 @@ RCT_NOT_IMPLEMENTED(-init) if (_secure) { - NSMutableDictionary *SSLOptions = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *SSLOptions = [NSMutableDictionary new]; [_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel]; @@ -1478,7 +1478,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32; consumer = [_bufferedConsumers lastObject]; [_bufferedConsumers removeLastObject]; } else { - consumer = [[RCTSRIOConsumer alloc] init]; + consumer = [RCTSRIOConsumer new]; } [consumer setupWithScanner:scanner handler:handler bytesNeeded:bytesNeeded readToCurrentFrame:readToCurrentFrame unmaskBytes:unmaskBytes]; @@ -1579,7 +1579,7 @@ static NSRunLoop *networkRunLoop = nil; { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - networkThread = [[_RCTSRRunLoopThread alloc] init]; + networkThread = [_RCTSRRunLoopThread new]; networkThread.name = @"com.squareup.SocketRocket.NetworkThread"; [networkThread start]; networkRunLoop = networkThread.runLoop; diff --git a/Libraries/WebSocket/RCTWebSocketExecutor.m b/Libraries/WebSocket/RCTWebSocketExecutor.m index df661a54b..bd9600d3c 100644 --- a/Libraries/WebSocket/RCTWebSocketExecutor.m +++ b/Libraries/WebSocket/RCTWebSocketExecutor.m @@ -57,8 +57,8 @@ RCT_EXPORT_MODULE() _jsQueue = dispatch_queue_create("com.facebook.React.WebSocketExecutor", DISPATCH_QUEUE_SERIAL); _socket = [[RCTSRWebSocket alloc] initWithURL:_url]; _socket.delegate = self; - _callbacks = [[RCTSparseArray alloc] init]; - _injectedObjects = [[NSMutableDictionary alloc] init]; + _callbacks = [RCTSparseArray new]; + _injectedObjects = [NSMutableDictionary new]; [_socket setDelegateDispatchQueue:_jsQueue]; NSURL *startDevToolsURL = [NSURL URLWithString:@"/launch-chrome-devtools" relativeToURL:_url]; diff --git a/Libraries/WebSocket/RCTWebSocketManager.m b/Libraries/WebSocket/RCTWebSocketManager.m index c842cedc6..28d6c3ed0 100644 --- a/Libraries/WebSocket/RCTWebSocketManager.m +++ b/Libraries/WebSocket/RCTWebSocketManager.m @@ -45,7 +45,7 @@ RCT_EXPORT_MODULE() - (instancetype)init { if ((self = [super init])) { - _sockets = [[RCTSparseArray alloc] init]; + _sockets = [RCTSparseArray new]; } return self; } diff --git a/React/Base/RCTAssert.m b/React/Base/RCTAssert.m index a990f7c1b..b3d729634 100644 --- a/React/Base/RCTAssert.m +++ b/React/Base/RCTAssert.m @@ -72,7 +72,7 @@ void RCTPerformBlockWithAssertFunction(void (^block)(void), RCTAssertFunction as NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; NSMutableArray *functionStack = threadDictionary[RCTAssertFunctionStack]; if (!functionStack) { - functionStack = [[NSMutableArray alloc] init]; + functionStack = [NSMutableArray new]; threadDictionary[RCTAssertFunctionStack] = functionStack; } [functionStack addObject:assertFunction]; diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 7af103b31..c8387242c 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -89,10 +89,10 @@ id RCTGetLatestExecutor(void) */ _valid = YES; _loading = YES; - _moduleDataByID = [[NSMutableArray alloc] init]; - _frameUpdateObservers = [[NSMutableSet alloc] init]; - _scheduledCalls = [[NSMutableArray alloc] init]; - _scheduledCallbacks = [[RCTSparseArray alloc] init]; + _moduleDataByID = [NSMutableArray new]; + _frameUpdateObservers = [NSMutableSet new]; + _scheduledCalls = [NSMutableArray new]; + _scheduledCallbacks = [RCTSparseArray new]; _jsDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_jsThreadUpdate:)]; if (RCT_DEV) { @@ -213,7 +213,7 @@ id RCTGetLatestExecutor(void) RCTAssertMainThread(); // Register passed-in module instances - NSMutableDictionary *preregisteredModules = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *preregisteredModules = [NSMutableDictionary new]; NSArray *extraModules = nil; if (self.delegate) { @@ -229,7 +229,7 @@ id RCTGetLatestExecutor(void) } // Instantiate modules - _moduleDataByID = [[NSMutableArray alloc] init]; + _moduleDataByID = [NSMutableArray new]; NSMutableDictionary *modulesByName = [preregisteredModules mutableCopy]; for (Class moduleClass in RCTGetModuleClasses()) { NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass); @@ -241,7 +241,7 @@ id RCTGetLatestExecutor(void) // Preregistered instances takes precedence, no questions asked if (!preregisteredModules[moduleName]) { // It's OK to have a name collision as long as the second instance is nil - RCTAssert([[moduleClass alloc] init] == nil, + RCTAssert([moduleClass new] == nil, @"Attempted to register RCTBridgeModule class %@ for the name " "'%@', but name was already registered by class %@", moduleClass, moduleName, [modulesByName[moduleName] class]); @@ -254,7 +254,7 @@ id RCTGetLatestExecutor(void) } } else { // Module name hasn't been used before, so go ahead and instantiate - module = [[moduleClass alloc] init]; + module = [moduleClass new]; } if (module) { modulesByName[moduleName] = module; @@ -299,7 +299,7 @@ id RCTGetLatestExecutor(void) - (NSString *)moduleConfig { - NSMutableDictionary *config = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *config = [NSMutableDictionary new]; for (RCTModuleData *moduleData in _moduleDataByID) { config[moduleData.name] = moduleData.config; if ([moduleData.instance conformsToProtocol:@protocol(RCTFrameUpdateObserver)]) { @@ -667,7 +667,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL } NSMutableOrderedSet *set = [buckets objectForKey:moduleData]; if (!set) { - set = [[NSMutableOrderedSet alloc] init]; + set = [NSMutableOrderedSet new]; [buckets setObject:set forKey:moduleData]; } [set addObject:@(i)]; @@ -785,8 +785,8 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL ) if (calls.count > 0) { - _scheduledCalls = [[NSMutableArray alloc] init]; - _scheduledCallbacks = [[RCTSparseArray alloc] init]; + _scheduledCalls = [NSMutableArray new]; + _scheduledCallbacks = [RCTSparseArray new]; [self _actuallyInvokeAndProcessModule:@"BatchedBridge" method:@"processBatch" arguments:@[[calls valueForKey:@"js_args"]]]; diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index fd06342b3..2efe49f94 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -57,7 +57,7 @@ void RCTRegisterModule(Class moduleClass) { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - RCTModuleClasses = [[NSMutableArray alloc] init]; + RCTModuleClasses = [NSMutableArray new]; }); RCTAssert([moduleClass conformsToProtocol:@protocol(RCTBridgeModule)], diff --git a/React/Base/RCTCache.m b/React/Base/RCTCache.m index a0646a401..b61922ae4 100644 --- a/React/Base/RCTCache.m +++ b/React/Base/RCTCache.m @@ -57,9 +57,9 @@ if ((self = [super init])) { //create storage - _cache = [[NSMutableDictionary alloc] init]; - _entryPool = [[NSMutableArray alloc] init]; - _lock = [[NSLock alloc] init]; + _cache = [NSMutableDictionary new]; + _entryPool = [NSMutableArray new]; + _lock = [NSLock new]; _totalCost = 0; #if TARGET_OS_IPHONE @@ -256,7 +256,7 @@ _totalCost += g; RCTCacheEntry *entry = _cache[key]; if (!entry) { - entry = [[RCTCacheEntry alloc] init]; + entry = [RCTCacheEntry new]; _cache[key] = entry; } entry.object = obj; diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index 51134f98e..c0d0ac0e2 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -60,7 +60,7 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod + (NSIndexSet *)NSIndexSet:(id)json { json = [self NSNumberArray:json]; - NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] init]; + NSMutableIndexSet *indexSet = [NSMutableIndexSet new]; for (NSNumber *number in json) { NSInteger index = number.integerValue; if (RCT_DEBUG && index < 0) { @@ -139,7 +139,7 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod static NSDateFormatter *formatter; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - formatter = [[NSDateFormatter alloc] init]; + formatter = [NSDateFormatter new]; formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"; formatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]; formatter.timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; @@ -383,7 +383,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[ static RCTCache *colorCache = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - colorCache = [[RCTCache alloc] init]; + colorCache = [RCTCache new]; colorCache.countLimit = 128; }); UIColor *color = colorCache[json]; @@ -702,7 +702,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[ // but to use +[UIImage imageNamed] - but this method isn't thread safe static NSMutableDictionary *XCAssetMap = nil; if (!XCAssetMap) { - XCAssetMap = [[NSMutableDictionary alloc] init]; + XCAssetMap = [NSMutableDictionary new]; } NSNumber *isAsset = XCAssetMap[path]; if (!isAsset || isAsset.boolValue) { @@ -986,7 +986,7 @@ RCT_JSON_ARRAY_CONVERTER(NSNumber) // Can't use RCT_ARRAY_CONVERTER due to bridged cast + (NSArray *)CGColorArray:(id)json { - NSMutableArray *colors = [[NSMutableArray alloc] init]; + NSMutableArray *colors = [NSMutableArray new]; for (id value in [self NSArray:json]) { [colors addObject:(__bridge id)[self CGColor:value]]; } diff --git a/React/Base/RCTEventDispatcher.m b/React/Base/RCTEventDispatcher.m index 135bf93a5..5e6ac6b4d 100644 --- a/React/Base/RCTEventDispatcher.m +++ b/React/Base/RCTEventDispatcher.m @@ -99,8 +99,8 @@ RCT_EXPORT_MODULE() - (instancetype)init { if ((self = [super init])) { - _eventQueue = [[NSMutableDictionary alloc] init]; - _eventQueueLock = [[NSLock alloc] init]; + _eventQueue = [NSMutableDictionary new]; + _eventQueueLock = [NSLock new]; } return self; } @@ -176,7 +176,7 @@ RCT_EXPORT_MODULE() - (void)dispatchEvent:(id)event { - NSMutableArray *arguments = [[NSMutableArray alloc] init]; + NSMutableArray *arguments = [NSMutableArray new]; if (event.viewTag) { [arguments addObject:event.viewTag]; @@ -201,7 +201,7 @@ RCT_EXPORT_MODULE() { [_eventQueueLock lock]; NSDictionary *eventQueue = _eventQueue; - _eventQueue = [[NSMutableDictionary alloc] init]; + _eventQueue = [NSMutableDictionary new]; _paused = YES; [_eventQueueLock unlock]; diff --git a/React/Base/RCTFPSGraph.m b/React/Base/RCTFPSGraph.m index 1aa5efd7d..c5580a2f4 100644 --- a/React/Base/RCTFPSGraph.m +++ b/React/Base/RCTFPSGraph.m @@ -72,7 +72,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) - (CAShapeLayer *)createGraph:(UIColor *)color { CGFloat left = _position & RCTFPSGraphPositionLeft ? 0 : _length; - CAShapeLayer *graph = [[CAShapeLayer alloc] init]; + CAShapeLayer *graph = [CAShapeLayer new]; graph.frame = CGRectMake(left, 0, 2 * _margin + _length, self.frame.size.height); graph.backgroundColor = [[color colorWithAlphaComponent:.2] CGColor]; graph.fillColor = [color CGColor]; diff --git a/React/Base/RCTJavaScriptLoader.m b/React/Base/RCTJavaScriptLoader.m index 3a69aaf96..021d9a065 100755 --- a/React/Base/RCTJavaScriptLoader.m +++ b/React/Base/RCTJavaScriptLoader.m @@ -68,7 +68,7 @@ RCT_NOT_IMPLEMENTED(-init) NSDictionary *errorDetails = RCTJSONParse(rawText, nil); if ([errorDetails isKindOfClass:[NSDictionary class]] && [errorDetails[@"errors"] isKindOfClass:[NSArray class]]) { - NSMutableArray *fakeStack = [[NSMutableArray alloc] init]; + NSMutableArray *fakeStack = [NSMutableArray new]; for (NSDictionary *err in errorDetails[@"errors"]) { [fakeStack addObject: @{ @"methodName": err[@"description"] ?: @"", diff --git a/React/Base/RCTKeyCommands.m b/React/Base/RCTKeyCommands.m index a9d358482..d3b80ac55 100644 --- a/React/Base/RCTKeyCommands.m +++ b/React/Base/RCTKeyCommands.m @@ -152,7 +152,7 @@ RCT_NOT_IMPLEMENTED(-init) static RCTKeyCommands *sharedInstance; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - sharedInstance = [[self alloc] init]; + sharedInstance = [self new]; }); return sharedInstance; @@ -161,7 +161,7 @@ RCT_NOT_IMPLEMENTED(-init) - (instancetype)init { if ((self = [super init])) { - _commands = [[NSMutableSet alloc] init]; + _commands = [NSMutableSet new]; } return self; } diff --git a/React/Base/RCTLog.m b/React/Base/RCTLog.m index 3fa343303..7e530664f 100644 --- a/React/Base/RCTLog.m +++ b/React/Base/RCTLog.m @@ -171,7 +171,7 @@ void RCTPerformBlockWithLogFunction(void (^block)(void), RCTLogFunction logFunct NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; NSMutableArray *functionStack = threadDictionary[RCTLogFunctionStack]; if (!functionStack) { - functionStack = [[NSMutableArray alloc] init]; + functionStack = [NSMutableArray new]; threadDictionary[RCTLogFunctionStack] = functionStack; } [functionStack addObject:logFunction]; @@ -196,12 +196,12 @@ NSString *RCTFormatLog( NSNumber *lineNumber, NSString *message ) { - NSMutableString *log = [[NSMutableString alloc] init]; + NSMutableString *log = [NSMutableString new]; if (timestamp) { static NSDateFormatter *formatter; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - formatter = [[NSDateFormatter alloc] init]; + formatter = [NSDateFormatter new]; formatter.dateFormat = formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS "; }); [log appendString:[formatter stringFromDate:timestamp]]; diff --git a/React/Base/RCTModuleData.m b/React/Base/RCTModuleData.m index c4c248643..3d492c8b2 100644 --- a/React/Base/RCTModuleData.m +++ b/React/Base/RCTModuleData.m @@ -49,7 +49,7 @@ RCT_NOT_IMPLEMENTED(-init); - (NSArray *)methods { if (!_methods) { - NSMutableArray *moduleMethods = [[NSMutableArray alloc] init]; + NSMutableArray *moduleMethods = [NSMutableArray new]; unsigned int methodCount; Method *methods = class_copyMethodList(object_getClass(_moduleClass), &methodCount); @@ -77,14 +77,14 @@ RCT_NOT_IMPLEMENTED(-init); - (NSDictionary *)config { - NSMutableDictionary *config = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *config = [NSMutableDictionary new]; config[@"moduleID"] = _moduleID; if (_constants) { config[@"constants"] = _constants; } - NSMutableDictionary *methodconfig = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *methodconfig = [NSMutableDictionary new]; [self.methods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger idx, __unused BOOL *stop) { methodconfig[method.JSMethodName] = @{ @"methodID": @(idx), diff --git a/React/Base/RCTPerfStats.m b/React/Base/RCTPerfStats.m index 39f72928f..2f025a03b 100644 --- a/React/Base/RCTPerfStats.m +++ b/React/Base/RCTPerfStats.m @@ -32,7 +32,7 @@ RCT_EXPORT_MODULE() - (UIView *)container { if (!_container) { - _container = [[UIView alloc] init]; + _container = [UIView new]; _container.backgroundColor = [UIColor colorWithRed:0 green:0 blue:34/255.0 alpha:1]; _container.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth; } diff --git a/React/Base/RCTProfile.m b/React/Base/RCTProfile.m index a7021415f..2de44b206 100644 --- a/React/Base/RCTProfile.m +++ b/React/Base/RCTProfile.m @@ -216,14 +216,14 @@ void RCTProfileInit(RCTBridge *bridge) static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - _RCTProfileLock = [[NSRecursiveLock alloc] init]; + _RCTProfileLock = [NSRecursiveLock new]; }); RCTProfileLock( RCTProfileStartTime = CACurrentMediaTime(); - RCTProfileOngoingEvents = [[NSMutableDictionary alloc] init]; + RCTProfileOngoingEvents = [NSMutableDictionary new]; RCTProfileInfo = @{ - RCTProfileTraceEvents: [[NSMutableArray alloc] init], - RCTProfileSamples: [[NSMutableArray alloc] init], + RCTProfileTraceEvents: [NSMutableArray new], + RCTProfileSamples: [NSMutableArray new], }; ); diff --git a/React/Base/RCTRedBox.m b/React/Base/RCTRedBox.m index 862b360a7..0af8ac819 100644 --- a/React/Base/RCTRedBox.m +++ b/React/Base/RCTRedBox.m @@ -41,7 +41,7 @@ self.backgroundColor = _redColor; self.hidden = YES; - UIViewController *rootController = [[UIViewController alloc] init]; + UIViewController *rootController = [UIViewController new]; self.rootViewController = rootController; _rootView = rootController.view; _rootView.backgroundColor = [UIColor clearColor]; @@ -102,7 +102,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) { NSData *stackFrameJSON = [RCTJSONStringify(stackFrame, nil) dataUsingEncoding:NSUTF8StringEncoding]; NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[stackFrameJSON length]]; - NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; + NSMutableURLRequest *request = [NSMutableURLRequest new]; request.URL = [RCTConvert NSURL:@"http://localhost:8081/open-stack-frame"]; request.HTTPMethod = @"POST"; request.HTTPBody = stackFrameJSON; @@ -200,7 +200,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) cell.detailTextLabel.font = [UIFont fontWithName:@"Menlo-Regular" size:11]; cell.detailTextLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; cell.backgroundColor = [UIColor clearColor]; - cell.selectedBackgroundView = [[UIView alloc] init]; + cell.selectedBackgroundView = [UIView new]; cell.selectedBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2]; } @@ -279,7 +279,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) static RCTRedBox *_sharedInstance; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - _sharedInstance = [[RCTRedBox alloc] init]; + _sharedInstance = [RCTRedBox new]; }); return _sharedInstance; } diff --git a/React/Base/RCTSparseArray.m b/React/Base/RCTSparseArray.m index 2332f96c5..236e64d17 100644 --- a/React/Base/RCTSparseArray.m +++ b/React/Base/RCTSparseArray.m @@ -37,7 +37,7 @@ + (instancetype)sparseArray { - return [[self alloc] init]; + return [self new]; } + (instancetype)sparseArrayWithCapacity:(NSUInteger)capacity diff --git a/React/Base/RCTTouchHandler.m b/React/Base/RCTTouchHandler.m index cf84ecdf7..3dd64bbdf 100644 --- a/React/Base/RCTTouchHandler.m +++ b/React/Base/RCTTouchHandler.m @@ -48,9 +48,9 @@ _bridge = bridge; _dispatchedInitialTouches = NO; - _nativeTouches = [[NSMutableOrderedSet alloc] init]; - _reactTouches = [[NSMutableArray alloc] init]; - _touchViews = [[NSMutableArray alloc] init]; + _nativeTouches = [NSMutableOrderedSet new]; + _reactTouches = [NSMutableArray new]; + _touchViews = [NSMutableArray new]; // `cancelsTouchesInView` is needed in order to be used as a top level // event delegated recognizer. Otherwise, lower-level components not built @@ -168,7 +168,7 @@ typedef NS_ENUM(NSInteger, RCTTouchEventType) { originatingTime:(__unused CFTimeInterval)originatingTime { // Update touches - NSMutableArray *changedIndexes = [[NSMutableArray alloc] init]; + NSMutableArray *changedIndexes = [NSMutableArray new]; for (UITouch *touch in touches) { NSInteger index = [_nativeTouches indexOfObject:touch]; if (index == NSNotFound) { diff --git a/React/Executors/RCTContextExecutor.m b/React/Executors/RCTContextExecutor.m index 8c8174773..9eb147dbf 100644 --- a/React/Executors/RCTContextExecutor.m +++ b/React/Executors/RCTContextExecutor.m @@ -142,7 +142,7 @@ static JSValueRef RCTConsoleProfile(JSContextRef context, __unused JSObjectRef o { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - profiles = [[NSMutableArray alloc] init]; + profiles = [NSMutableArray new]; }); static int profileCounter = 1; diff --git a/React/Executors/RCTWebViewExecutor.m b/React/Executors/RCTWebViewExecutor.m index 539b9e779..14c21e8b2 100644 --- a/React/Executors/RCTWebViewExecutor.m +++ b/React/Executors/RCTWebViewExecutor.m @@ -66,10 +66,10 @@ RCT_EXPORT_MODULE() - (void)setUp { if (!_webView) { - _webView = [[UIWebView alloc] init]; + _webView = [UIWebView new]; } - _objectsToInject = [[NSMutableDictionary alloc] init]; + _objectsToInject = [NSMutableDictionary new]; _commentsRegex = [NSRegularExpression regularExpressionWithPattern:@"(^ *?\\/\\/.*?$|\\/\\*\\*[\\s\\S]*?\\*\\/)" options:NSRegularExpressionAnchorsMatchLines error:NULL], _scriptTagsRegex = [NSRegularExpression regularExpressionWithPattern:@"<(\\/?script[^>]*?)>" options:0 error:NULL], _webView.delegate = self; diff --git a/React/Modules/RCTAccessibilityManager.m b/React/Modules/RCTAccessibilityManager.m index 7fc58786a..d016e6a01 100644 --- a/React/Modules/RCTAccessibilityManager.m +++ b/React/Modules/RCTAccessibilityManager.m @@ -129,7 +129,7 @@ RCT_EXPORT_MODULE() RCT_EXPORT_METHOD(setAccessibilityContentSizeMultipliers:(NSDictionary *)JSMultipliers) { - NSMutableDictionary *multipliers = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *multipliers = [NSMutableDictionary new]; for (NSString *__nonnull JSCategory in JSMultipliers) { NSNumber *m = JSMultipliers[JSCategory]; NSString *UIKitCategory = [self.class UIKitCategoryFromJSCategory:JSCategory]; diff --git a/React/Modules/RCTAlertManager.m b/React/Modules/RCTAlertManager.m index f93ef812a..ea8cd9d90 100644 --- a/React/Modules/RCTAlertManager.m +++ b/React/Modules/RCTAlertManager.m @@ -28,9 +28,9 @@ RCT_EXPORT_MODULE() - (instancetype)init { if ((self = [super init])) { - _alerts = [[NSMutableArray alloc] init]; - _alertCallbacks = [[NSMutableArray alloc] init]; - _alertButtonKeys = [[NSMutableArray alloc] init]; + _alerts = [NSMutableArray new]; + _alertCallbacks = [NSMutableArray new]; + _alertButtonKeys = [NSMutableArray new]; } return self; } diff --git a/React/Modules/RCTAsyncLocalStorage.m b/React/Modules/RCTAsyncLocalStorage.m index 923a3a14a..262b578be 100644 --- a/React/Modules/RCTAsyncLocalStorage.m +++ b/React/Modules/RCTAsyncLocalStorage.m @@ -161,7 +161,7 @@ RCT_EXPORT_MODULE() RCTDeleteStorageDirectory(); } _clearOnInvalidate = NO; - _manifest = [[NSMutableDictionary alloc] init]; + _manifest = [NSMutableDictionary new]; _haveSetup = NO; } @@ -199,10 +199,10 @@ RCT_EXPORT_MODULE() if (!_haveSetup) { NSDictionary *errorOut; NSString *serialized = RCTReadFile(RCTGetManifestFilePath(), nil, &errorOut); - _manifest = serialized ? [RCTJSONParse(serialized, &error) mutableCopy] : [[NSMutableDictionary alloc] init]; + _manifest = serialized ? [RCTJSONParse(serialized, &error) mutableCopy] : [NSMutableDictionary new]; if (error) { RCTLogWarn(@"Failed to parse manifest - creating new one.\n\n%@", error); - _manifest = [[NSMutableDictionary alloc] init]; + _manifest = [NSMutableDictionary new]; } _haveSetup = YES; } @@ -377,7 +377,7 @@ RCT_EXPORT_METHOD(multiRemove:(NSArray *)keys RCT_EXPORT_METHOD(clear:(RCTResponseSenderBlock)callback) { - _manifest = [[NSMutableDictionary alloc] init]; + _manifest = [NSMutableDictionary new]; NSError *error = RCTDeleteStorageDirectory(); if (callback) { callback(@[RCTNullIfNil(error)]); diff --git a/React/Modules/RCTDevMenu.m b/React/Modules/RCTDevMenu.m index 32f3946b1..08d2ebe26 100644 --- a/React/Modules/RCTDevMenu.m +++ b/React/Modules/RCTDevMenu.m @@ -125,7 +125,7 @@ RCT_EXPORT_MODULE() object:nil]; _defaults = [NSUserDefaults standardUserDefaults]; - _settings = [[NSMutableDictionary alloc] init]; + _settings = [NSMutableDictionary new]; _extraMenuItems = [NSMutableArray array]; // Delay setup until after Bridge init @@ -331,7 +331,7 @@ RCT_EXPORT_METHOD(show) return; } - UIActionSheet *actionSheet = [[UIActionSheet alloc] init]; + UIActionSheet *actionSheet = [UIActionSheet new]; actionSheet.title = @"React Native: Development"; actionSheet.delegate = self; diff --git a/React/Modules/RCTTiming.m b/React/Modules/RCTTiming.m index a776c58dc..09adc9560 100644 --- a/React/Modules/RCTTiming.m +++ b/React/Modules/RCTTiming.m @@ -78,7 +78,7 @@ RCT_EXPORT_MODULE() { if ((self = [super init])) { _paused = YES; - _timers = [[RCTSparseArray alloc] init]; + _timers = [RCTSparseArray new]; for (NSString *name in @[UIApplicationWillResignActiveNotification, UIApplicationDidEnterBackgroundNotification, @@ -134,7 +134,7 @@ RCT_EXPORT_MODULE() - (void)didUpdateFrame:(__unused RCTFrameUpdate *)update { - NSMutableArray *timersToCall = [[NSMutableArray alloc] init]; + NSMutableArray *timersToCall = [NSMutableArray new]; for (RCTTimer *timer in _timers.allObjects) { if ([timer updateFoundNeedsJSUpdate]) { [timersToCall addObject:timer.callbackID]; diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index d1a29d3a8..7f72a8074 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -219,16 +219,16 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls); _shadowQueue = dispatch_queue_create("com.facebook.React.ShadowQueue", DISPATCH_QUEUE_SERIAL); - _pendingUIBlocksLock = [[NSLock alloc] init]; + _pendingUIBlocksLock = [NSLock new]; - _shadowViewRegistry = [[RCTSparseArray alloc] init]; - _viewRegistry = [[RCTSparseArray alloc] init]; + _shadowViewRegistry = [RCTSparseArray new]; + _viewRegistry = [RCTSparseArray new]; // Internal resources - _pendingUIBlocks = [[NSMutableArray alloc] init]; - _rootViewTags = [[NSMutableSet alloc] init]; + _pendingUIBlocks = [NSMutableArray new]; + _rootViewTags = [NSMutableSet new]; - _bridgeTransactionListeners = [[NSMutableSet alloc] init]; + _bridgeTransactionListeners = [NSMutableSet new]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNewContentSizeMultiplier) @@ -284,10 +284,10 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls); RCTAssert(_bridge == nil, @"Should not re-use same UIIManager instance"); _bridge = bridge; - _shadowViewRegistry = [[RCTSparseArray alloc] init]; + _shadowViewRegistry = [RCTSparseArray new]; // Get view managers from bridge - NSMutableDictionary *componentDataByName = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *componentDataByName = [NSMutableDictionary new]; for (RCTViewManager *manager in _bridge.modules.allValues) { if ([manager isKindOfClass:[RCTViewManager class]]) { RCTComponentData *componentData = [[RCTComponentData alloc] initWithManager:manager]; @@ -326,7 +326,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls); if (!_viewRegistry) { return; } - RCTShadowView *shadowView = [[RCTShadowView alloc] init]; + RCTShadowView *shadowView = [RCTShadowView new]; shadowView.reactTag = reactTag; shadowView.frame = frame; shadowView.backgroundColor = rootView.backgroundColor; @@ -479,7 +479,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls); // reactSetFrame: has been called. Note that if reactSetFrame: is not called, // these won't be called either, so this is not a suitable place to update // properties that aren't related to layout. - NSMutableArray *updateBlocks = [[NSMutableArray alloc] init]; + NSMutableArray *updateBlocks = [NSMutableArray new]; for (RCTShadowView *shadowView in viewsWithNewFrames) { RCTViewManager *manager = [_componentDataByName[shadowView.viewName] manager]; RCTViewManagerUIBlock block = [manager uiBlockToAmendWithShadowView:shadowView]; @@ -870,7 +870,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po // processing the pending blocks in another thread. [_pendingUIBlocksLock lock]; NSArray *previousPendingUIBlocks = _pendingUIBlocks; - _pendingUIBlocks = [[NSMutableArray alloc] init]; + _pendingUIBlocks = [NSMutableArray new]; [_pendingUIBlocksLock unlock]; // Execute the previously queued UI blocks @@ -1130,7 +1130,7 @@ RCT_EXPORT_METHOD(clearJSResponder) - (NSDictionary *)bubblingEventsConfig { - NSMutableDictionary *customBubblingEventTypesConfigs = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *customBubblingEventTypesConfigs = [NSMutableDictionary new]; for (RCTComponentData *componentData in _componentDataByName.allValues) { RCTViewManager *manager = componentData.manager; if (RCTClassOverridesInstanceMethod([manager class], @selector(customBubblingEventTypes))) { @@ -1160,7 +1160,7 @@ RCT_EXPORT_METHOD(clearJSResponder) - (NSDictionary *)directEventsConfig { - NSMutableDictionary *customDirectEventTypes = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *customDirectEventTypes = [NSMutableDictionary new]; for (RCTComponentData *componentData in _componentDataByName.allValues) { RCTViewManager *manager = componentData.manager; if (RCTClassOverridesInstanceMethod([manager class], @selector(customDirectEventTypes))) { diff --git a/React/Views/RCTActivityIndicatorViewManager.m b/React/Views/RCTActivityIndicatorViewManager.m index 3876400df..2a7cadf35 100644 --- a/React/Views/RCTActivityIndicatorViewManager.m +++ b/React/Views/RCTActivityIndicatorViewManager.m @@ -29,7 +29,7 @@ RCT_EXPORT_MODULE() - (UIView *)view { - return [[UIActivityIndicatorView alloc] init]; + return [UIActivityIndicatorView new]; } RCT_EXPORT_VIEW_PROPERTY(color, UIColor) diff --git a/React/Views/RCTComponentData.m b/React/Views/RCTComponentData.m index 2f3aa8458..462513c53 100644 --- a/React/Views/RCTComponentData.m +++ b/React/Views/RCTComponentData.m @@ -48,8 +48,8 @@ typedef void (^RCTPropBlock)(id view, id json); { if ((self = [super init])) { _manager = manager; - _viewPropBlocks = [[NSMutableDictionary alloc] init]; - _shadowPropBlocks = [[NSMutableDictionary alloc] init]; + _viewPropBlocks = [NSMutableDictionary new]; + _shadowPropBlocks = [NSMutableDictionary new]; _name = RCTBridgeModuleNameForClass([manager class]); RCTAssert(_name.length, @"Invalid moduleName '%@'", _name); @@ -292,7 +292,7 @@ RCT_NOT_IMPLEMENTED(-init) - (NSDictionary *)viewConfig { Class managerClass = [_manager class]; - NSMutableDictionary *propTypes = [[NSMutableDictionary alloc] init]; + NSMutableDictionary *propTypes = [NSMutableDictionary new]; unsigned int count = 0; Method *methods = class_copyMethodList(object_getClass(managerClass), &count); diff --git a/React/Views/RCTConvert+MapKit.m b/React/Views/RCTConvert+MapKit.m index a1ba0ac98..9206c3a40 100644 --- a/React/Views/RCTConvert+MapKit.m +++ b/React/Views/RCTConvert+MapKit.m @@ -35,7 +35,7 @@ json = [self NSDictionary:json]; // TODO: more shape types - MKShape *shape = [[MKPointAnnotation alloc] init]; + MKShape *shape = [MKPointAnnotation new]; shape.coordinate = [self CLLocationCoordinate2D:json]; shape.title = [RCTConvert NSString:json[@"title"]]; shape.subtitle = [RCTConvert NSString:json[@"subtitle"]]; @@ -53,7 +53,7 @@ RCT_ENUM_CONVERTER(MKMapType, (@{ + (RCTPointAnnotation *)RCTPointAnnotation:(id)json { json = [self NSDictionary:json]; - RCTPointAnnotation *shape = [[RCTPointAnnotation alloc] init]; + RCTPointAnnotation *shape = [RCTPointAnnotation new]; shape.coordinate = [self CLLocationCoordinate2D:json]; shape.title = [RCTConvert NSString:json[@"title"]]; shape.subtitle = [RCTConvert NSString:json[@"subtitle"]]; diff --git a/React/Views/RCTDatePickerManager.m b/React/Views/RCTDatePickerManager.m index a5d63786f..229abb785 100644 --- a/React/Views/RCTDatePickerManager.m +++ b/React/Views/RCTDatePickerManager.m @@ -34,7 +34,7 @@ RCT_EXPORT_MODULE() // while the UIDatePicker is still sending onChange events. To // fix this we should maybe subclass UIDatePicker and make it // be its own event target. - UIDatePicker *picker = [[UIDatePicker alloc] init]; + UIDatePicker *picker = [UIDatePicker new]; [picker addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged]; return picker; @@ -58,7 +58,7 @@ RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone) - (NSDictionary *)constantsToExport { - UIDatePicker *view = [[UIDatePicker alloc] init]; + UIDatePicker *view = [UIDatePicker new]; return @{ @"ComponentHeight": @(view.intrinsicContentSize.height), @"ComponentWidth": @(view.intrinsicContentSize.width), diff --git a/React/Views/RCTMap.m b/React/Views/RCTMap.m index d51af5a01..16208957b 100644 --- a/React/Views/RCTMap.m +++ b/React/Views/RCTMap.m @@ -80,7 +80,7 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01; { if (self.showsUserLocation != showsUserLocation) { if (showsUserLocation && !_locationManager) { - _locationManager = [[CLLocationManager alloc] init]; + _locationManager = [CLLocationManager new]; if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [_locationManager requestWhenInUseAuthorization]; } @@ -114,9 +114,9 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01; - (void)setAnnotations:(RCTPointAnnotationArray *)annotations { - NSMutableArray *newAnnotationIds = [[NSMutableArray alloc] init]; - NSMutableArray *annotationsToDelete = [[NSMutableArray alloc] init]; - NSMutableArray *annotationsToAdd = [[NSMutableArray alloc] init]; + NSMutableArray *newAnnotationIds = [NSMutableArray new]; + NSMutableArray *annotationsToDelete = [NSMutableArray new]; + NSMutableArray *annotationsToAdd = [NSMutableArray new]; for (RCTPointAnnotation *annotation in annotations) { if (![annotation isKindOfClass:[RCTPointAnnotation class]]) { @@ -150,7 +150,7 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01; [self addAnnotations:annotationsToAdd]; } - NSMutableArray *newIds = [[NSMutableArray alloc] init]; + NSMutableArray *newIds = [NSMutableArray new]; for (RCTPointAnnotation *anno in self.annotations) { if ([anno isKindOfClass:[MKUserLocation class]]) { continue; diff --git a/React/Views/RCTMapManager.m b/React/Views/RCTMapManager.m index 032da4d7a..130446df0 100644 --- a/React/Views/RCTMapManager.m +++ b/React/Views/RCTMapManager.m @@ -31,7 +31,7 @@ RCT_EXPORT_MODULE() - (UIView *)view { - RCTMap *map = [[RCTMap alloc] init]; + RCTMap *map = [RCTMap new]; map.delegate = self; return map; } diff --git a/React/Views/RCTModalHostView.m b/React/Views/RCTModalHostView.m index a4d1db93e..1650636ef 100644 --- a/React/Views/RCTModalHostView.m +++ b/React/Views/RCTModalHostView.m @@ -31,7 +31,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:coder) { if ((self = [super initWithFrame:CGRectZero])) { _bridge = bridge; - _modalViewController = [[RCTModalHostViewController alloc] init]; + _modalViewController = [RCTModalHostViewController new]; _touchHandler = [[RCTTouchHandler alloc] initWithBridge:bridge]; __weak RCTModalHostView *weakSelf = self; diff --git a/React/Views/RCTNavItemManager.m b/React/Views/RCTNavItemManager.m index 8350af2e9..f785934af 100644 --- a/React/Views/RCTNavItemManager.m +++ b/React/Views/RCTNavItemManager.m @@ -18,7 +18,7 @@ RCT_EXPORT_MODULE() - (UIView *)view { - return [[RCTNavItem alloc] init]; + return [RCTNavItem new]; } RCT_EXPORT_VIEW_PROPERTY(navigationBarHidden, BOOL) diff --git a/React/Views/RCTPickerManager.m b/React/Views/RCTPickerManager.m index 8e31e5fe9..6de76bcb7 100644 --- a/React/Views/RCTPickerManager.m +++ b/React/Views/RCTPickerManager.m @@ -27,7 +27,7 @@ RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger) - (NSDictionary *)constantsToExport { - UIPickerView *view = [[UIPickerView alloc] init]; + UIPickerView *view = [UIPickerView new]; return @{ @"ComponentHeight": @(view.intrinsicContentSize.height), @"ComponentWidth": @(view.intrinsicContentSize.width) diff --git a/React/Views/RCTProgressViewManager.m b/React/Views/RCTProgressViewManager.m index deb6285a6..0cd9049d3 100644 --- a/React/Views/RCTProgressViewManager.m +++ b/React/Views/RCTProgressViewManager.m @@ -26,7 +26,7 @@ RCT_EXPORT_MODULE() - (UIView *)view { - return [[UIProgressView alloc] init]; + return [UIProgressView new]; } RCT_EXPORT_VIEW_PROPERTY(progressViewStyle, UIProgressViewStyle) @@ -38,7 +38,7 @@ RCT_EXPORT_VIEW_PROPERTY(trackImage, UIImage) - (NSDictionary *)constantsToExport { - UIProgressView *view = [[UIProgressView alloc] init]; + UIProgressView *view = [UIProgressView new]; return @{ @"ComponentHeight": @(view.intrinsicContentSize.height), }; diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index 89afd8b63..9010bce8d 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -387,7 +387,7 @@ RCT_NOT_IMPLEMENTED(-init) _scrollEventThrottle = 0.0; _lastScrollDispatchTime = CACurrentMediaTime(); - _cachedChildFrames = [[NSMutableArray alloc] init]; + _cachedChildFrames = [NSMutableArray new]; [self addSubview:_scrollView]; } @@ -582,7 +582,7 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidZoom, RCTScrollEventTypeMove) - (NSArray *)calculateChildFramesData { - NSMutableArray *updatedChildFrames = [[NSMutableArray alloc] init]; + NSMutableArray *updatedChildFrames = [NSMutableArray new]; [[_contentView reactSubviews] enumerateObjectsUsingBlock: ^(UIView *subview, NSUInteger idx, __unused BOOL *stop) { diff --git a/React/Views/RCTSegmentedControlManager.m b/React/Views/RCTSegmentedControlManager.m index d7e1156ff..1c5621e7a 100644 --- a/React/Views/RCTSegmentedControlManager.m +++ b/React/Views/RCTSegmentedControlManager.m @@ -30,7 +30,7 @@ RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL) - (NSDictionary *)constantsToExport { - RCTSegmentedControl *view = [[RCTSegmentedControl alloc] init]; + RCTSegmentedControl *view = [RCTSegmentedControl new]; return @{ @"ComponentHeight": @(view.intrinsicContentSize.height), }; diff --git a/React/Views/RCTSliderManager.m b/React/Views/RCTSliderManager.m index 100c2b4c3..9ce7699d1 100644 --- a/React/Views/RCTSliderManager.m +++ b/React/Views/RCTSliderManager.m @@ -20,7 +20,7 @@ RCT_EXPORT_MODULE() - (UIView *)view { - RCTSlider *slider = [[RCTSlider alloc] init]; + RCTSlider *slider = [RCTSlider new]; [slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged]; [slider addTarget:self action:@selector(sliderTouchEnd:) forControlEvents:UIControlEventTouchUpInside]; [slider addTarget:self action:@selector(sliderTouchEnd:) forControlEvents:UIControlEventTouchUpOutside]; diff --git a/React/Views/RCTSwitchManager.m b/React/Views/RCTSwitchManager.m index 7b39afa89..42a54210c 100644 --- a/React/Views/RCTSwitchManager.m +++ b/React/Views/RCTSwitchManager.m @@ -20,7 +20,7 @@ RCT_EXPORT_MODULE() - (UIView *)view { - RCTSwitch *switcher = [[RCTSwitch alloc] init]; + RCTSwitch *switcher = [RCTSwitch new]; [switcher addTarget:self action:@selector(onChange:) forControlEvents:UIControlEventValueChanged]; diff --git a/React/Views/RCTTabBar.m b/React/Views/RCTTabBar.m index 4f14a943f..34c8a3b04 100644 --- a/React/Views/RCTTabBar.m +++ b/React/Views/RCTTabBar.m @@ -36,8 +36,8 @@ if ((self = [super initWithFrame:CGRectZero])) { _eventDispatcher = eventDispatcher; - _tabViews = [[NSMutableArray alloc] init]; - _tabController = [[UITabBarController alloc] init]; + _tabViews = [NSMutableArray new]; + _tabController = [UITabBarController new]; _tabController.delegate = self; [self addSubview:_tabController.view]; } diff --git a/React/Views/RCTTabBarItem.m b/React/Views/RCTTabBarItem.m index 24a22cf5f..0727a846f 100644 --- a/React/Views/RCTTabBarItem.m +++ b/React/Views/RCTTabBarItem.m @@ -20,7 +20,7 @@ - (UITabBarItem *)barItem { if (!_barItem) { - _barItem = [[UITabBarItem alloc] init]; + _barItem = [UITabBarItem new]; } return _barItem; } diff --git a/React/Views/RCTTabBarItemManager.m b/React/Views/RCTTabBarItemManager.m index d1a96ef2a..9adccfdd9 100644 --- a/React/Views/RCTTabBarItemManager.m +++ b/React/Views/RCTTabBarItemManager.m @@ -18,7 +18,7 @@ RCT_EXPORT_MODULE() - (UIView *)view { - return [[RCTTabBarItem alloc] init]; + return [RCTTabBarItem new]; } RCT_EXPORT_VIEW_PROPERTY(selected, BOOL); diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m index 9c7a97483..bf152ea39 100644 --- a/React/Views/RCTViewManager.m +++ b/React/Views/RCTViewManager.m @@ -56,12 +56,12 @@ RCT_EXPORT_MODULE() - (UIView *)view { - return [[RCTView alloc] init]; + return [RCTView new]; } - (RCTShadowView *)shadowView { - return [[RCTShadowView alloc] init]; + return [RCTShadowView new]; } - (NSArray *)customBubblingEventTypes