diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m b/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m index 85f73a314..267ed1409 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m @@ -29,7 +29,7 @@ RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)"); #endif - NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; + NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion; RCTAssert(version.majorVersion == 8 || version.minorVersion >= 3, @"Tests should be run on iOS 8.3+, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion); _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp", nil); } diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m b/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m index 923f32caa..c30b8d1dc 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m @@ -50,7 +50,7 @@ // Register 20 views to use in the tests for (NSInteger i = 1; i <= 20; i++) { UIView *registeredView = [UIView new]; - [registeredView setReactTag:@(i)]; + registeredView.reactTag = @(i); _uiManager.viewRegistry[i] = registeredView; } } @@ -92,7 +92,7 @@ NSArray *removeAtIndices = @[@0, @4, @8, @12, @16]; for (NSNumber *index in removeAtIndices) { - NSNumber *reactTag = @([index integerValue] + 2); + NSNumber *reactTag = @(index.integerValue + 2); [removedViews addObject:_uiManager.viewRegistry[reactTag]]; } for (NSInteger i = 2; i < 20; i++) { diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m b/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m index cb5d1771f..1281a4796 100644 --- a/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m +++ b/Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m @@ -36,7 +36,7 @@ RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)"); #endif - NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; + NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion; RCTAssert(version.majorVersion == 8 || version.minorVersion >= 3, @"Snapshot tests should be run on iOS 8.3+, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion); _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp.ios", nil); _runner.recordMode = NO; diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m index a4cf3150c..9be80dca9 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m @@ -49,7 +49,7 @@ // Register 20 views to use in the tests for (NSInteger i = 1; i <= 20; i++) { UIView *registeredView = [UIView new]; - [registeredView setReactTag:@(i)]; + registeredView.reactTag = @(i); _uiManager.viewRegistry[i] = registeredView; } } @@ -91,7 +91,7 @@ NSArray *removeAtIndices = @[@0, @4, @8, @12, @16]; for (NSNumber *index in removeAtIndices) { - NSNumber *reactTag = @([index integerValue] + 2); + NSNumber *reactTag = @(index.integerValue + 2); [removedViews addObject:_uiManager.viewRegistry[reactTag]]; } for (NSInteger i = 2; i < 20; i++) { diff --git a/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/Libraries/ActionSheetIOS/RCTActionSheetManager.m index 22abba34e..ecd522cee 100644 --- a/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ b/Libraries/ActionSheetIOS/RCTActionSheetManager.m @@ -60,7 +60,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options _callbacks[RCTKeyForInstance(actionSheet)] = successCallback; - UIWindow *appWindow = [[[UIApplication sharedApplication] delegate] window]; + UIWindow *appWindow = [UIApplication sharedApplication].delegate.window; if (appWindow == nil) { RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); return; @@ -81,12 +81,12 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options if (URL) { [items addObject:URL]; } - if ([items count] == 0) { + if (items.count == 0) { failureCallback(@[@"No `url` or `message` to share"]); return; } UIActivityViewController *share = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; - UIViewController *ctrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; + UIViewController *ctrl = [UIApplication sharedApplication].delegate.window.rootViewController; #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 @@ -126,7 +126,7 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options RCTLogWarn(@"No callback registered for action sheet: %@", actionSheet.title); } - [[[[UIApplication sharedApplication] delegate] window] makeKeyWindow]; + [[UIApplication sharedApplication].delegate.window makeKeyWindow]; } #pragma mark Private diff --git a/Libraries/Geolocation/RCTLocationObserver.m b/Libraries/Geolocation/RCTLocationObserver.m index 8efd16787..54857c265 100644 --- a/Libraries/Geolocation/RCTLocationObserver.m +++ b/Libraries/Geolocation/RCTLocationObserver.m @@ -252,7 +252,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { // Create event - CLLocation *location = [locations lastObject]; + CLLocation *location = locations.lastObject; _lastLocationEvent = @{ @"coords": @{ @"latitude": @(location.coordinate.latitude), diff --git a/Libraries/Image/RCTCameraRollManager.m b/Libraries/Image/RCTCameraRollManager.m index afe4d7284..e2f2a297f 100644 --- a/Libraries/Image/RCTCameraRollManager.m +++ b/Libraries/Image/RCTCameraRollManager.m @@ -34,12 +34,12 @@ RCT_EXPORT_METHOD(saveImageWithTag:(NSString *)imageTag errorCallback(loadError); return; } - [_bridge.assetsLibrary writeImageToSavedPhotosAlbum:[loadedImage CGImage] metadata:nil completionBlock:^(NSURL *assetURL, NSError *saveError) { + [_bridge.assetsLibrary writeImageToSavedPhotosAlbum:loadedImage.CGImage metadata:nil completionBlock:^(NSURL *assetURL, NSError *saveError) { if (saveError) { RCTLogWarn(@"Error saving cropped image: %@", saveError); errorCallback(saveError); } else { - successCallback(@[[assetURL absoluteString]]); + successCallback(@[assetURL.absoluteString]); } }]; }]; @@ -47,7 +47,7 @@ RCT_EXPORT_METHOD(saveImageWithTag:(NSString *)imageTag - (void)callCallback:(RCTResponseSenderBlock)callback withAssets:(NSArray *)assets hasNextPage:(BOOL)hasNextPage { - if (![assets count]) { + if (!assets.count) { callback(@[@{ @"edges": assets, @"page_info": @{ @@ -109,14 +109,14 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stopAssets) { if (result) { - NSString *uri = [(NSURL *)[result valueForProperty:ALAssetPropertyAssetURL] absoluteString]; + NSString *uri = ((NSURL *)[result valueForProperty:ALAssetPropertyAssetURL]).absoluteString; if (afterCursor && !foundAfter) { if ([afterCursor isEqualToString:uri]) { foundAfter = YES; } return; // Skip until we get to the first one } - if (first == [assets count]) { + if (first == assets.count) { *stopAssets = YES; *stopGroups = YES; hasNextPage = YES; @@ -138,7 +138,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params @"width": @(dimensions.width), @"isStored": @YES, }, - @"timestamp": @([date timeIntervalSince1970]), + @"timestamp": @(date.timeIntervalSince1970), @"location": loc ? @{ @"latitude": @(loc.coordinate.latitude), diff --git a/Libraries/Image/RCTGIFImage.m b/Libraries/Image/RCTGIFImage.m index 99704e305..4258262ed 100644 --- a/Libraries/Image/RCTGIFImage.m +++ b/Libraries/Image/RCTGIFImage.m @@ -85,7 +85,7 @@ CAKeyframeAnimation *RCTGIFImageWithFileURL(NSURL *URL) return nil; } - if (![URL isFileURL]) { + if (!URL.fileURL) { RCTLogError(@"Loading remote image URLs synchronously is a really bad idea."); return nil; } diff --git a/Libraries/Image/RCTImageLoader.m b/Libraries/Image/RCTImageLoader.m index 575842c46..a72e01ef2 100644 --- a/Libraries/Image/RCTImageLoader.m +++ b/Libraries/Image/RCTImageLoader.m @@ -170,7 +170,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation, // The 'ph://' prefix is used by FBMediaKit to differentiate between // assets-library. It is prepended to the local ID so that it is in the // form of an, NSURL which is what assets-library uses. - NSString *phAssetID = [imageTag substringFromIndex:[@"ph://" length]]; + NSString *phAssetID = [imageTag substringFromIndex:@"ph://".length]; PHFetchResult *results = [PHAsset fetchAssetsWithLocalIdentifiers:@[phAssetID] options:nil]; if (results.count == 0) { NSString *errorText = [NSString stringWithFormat:@"Failed to fetch PHAsset with local identifier %@ with no error message.", phAssetID]; @@ -179,7 +179,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation, return ^{}; } - PHAsset *asset = [results firstObject]; + PHAsset *asset = results.firstObject; PHImageRequestOptions *imageOptions = [PHImageRequestOptions new]; diff --git a/Libraries/Image/RCTImagePickerManager.m b/Libraries/Image/RCTImagePickerManager.m index 107f399b6..00a28a665 100644 --- a/Libraries/Image/RCTImagePickerManager.m +++ b/Libraries/Image/RCTImagePickerManager.m @@ -53,7 +53,7 @@ RCT_EXPORT_METHOD(openCameraDialog:(NSDictionary *)config successCallback:(RCTResponseSenderBlock)callback cancelCallback:(RCTResponseSenderBlock)cancelCallback) { - UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; UIViewController *rootViewController = keyWindow.rootViewController; UIImagePickerController *imagePicker = [UIImagePickerController new]; @@ -75,7 +75,7 @@ RCT_EXPORT_METHOD(openSelectDialog:(NSDictionary *)config successCallback:(RCTResponseSenderBlock)callback cancelCallback:(RCTResponseSenderBlock)cancelCallback) { - UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; UIViewController *rootViewController = keyWindow.rootViewController; UIImagePickerController *imagePicker = [UIImagePickerController new]; @@ -109,7 +109,7 @@ didFinishPickingMediaWithInfo:(NSDictionary *)info [_pickerCallbacks removeObjectAtIndex:index]; [_pickerCancelCallbacks removeObjectAtIndex:index]; - UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; UIViewController *rootViewController = keyWindow.rootViewController; [rootViewController dismissViewControllerAnimated:YES completion:nil]; @@ -125,7 +125,7 @@ didFinishPickingMediaWithInfo:(NSDictionary *)info [_pickerCallbacks removeObjectAtIndex:index]; [_pickerCancelCallbacks removeObjectAtIndex:index]; - UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; UIViewController *rootViewController = keyWindow.rootViewController; [rootViewController dismissViewControllerAnimated:YES completion:nil]; diff --git a/Libraries/Image/RCTImageRequestHandler.m b/Libraries/Image/RCTImageRequestHandler.m index 595c94247..1b3d76df1 100644 --- a/Libraries/Image/RCTImageRequestHandler.m +++ b/Libraries/Image/RCTImageRequestHandler.m @@ -22,13 +22,13 @@ RCT_EXPORT_MODULE() - (BOOL)canHandleRequest:(NSURLRequest *)request { - return [@[@"assets-library", @"ph"] containsObject:[request.URL.scheme lowercaseString]]; + return [@[@"assets-library", @"ph"] containsObject:request.URL.scheme.lowercaseString]; } - (id)sendRequest:(NSURLRequest *)request withDelegate:(id)delegate { - NSString *URLString = [request.URL absoluteString]; + NSString *URLString = request.URL.absoluteString; __block RCTImageLoaderCancellationBlock requestToken = nil; requestToken = [_bridge.imageLoader loadImageWithTag:URLString callback:^(NSError *error, UIImage *image) { diff --git a/Libraries/Image/RCTImageStoreManager.m b/Libraries/Image/RCTImageStoreManager.m index 2193dd01f..3ff66ce59 100644 --- a/Libraries/Image/RCTImageStoreManager.m +++ b/Libraries/Image/RCTImageStoreManager.m @@ -21,7 +21,7 @@ RCT_EXPORT_MODULE() -- (id)init +- (instancetype)init { if ((self = [super init])) { @@ -34,7 +34,7 @@ RCT_EXPORT_MODULE() - (NSString *)storeImage:(UIImage *)image { RCTAssertMainThread(); - NSString *tag = [NSString stringWithFormat:@"rct-image-store://%tu", [_store count]]; + NSString *tag = [NSString stringWithFormat:@"rct-image-store://%tu", _store.count]; _store[tag] = image; return tag; } @@ -101,13 +101,13 @@ RCT_EXPORT_METHOD(addImageFromBase64:(NSString *)base64String - (BOOL)canHandleRequest:(NSURLRequest *)request { - return [@[@"rct-image-store"] containsObject:[request.URL.scheme lowercaseString]]; + return [@[@"rct-image-store"] containsObject:request.URL.scheme.lowercaseString]; } - (id)sendRequest:(NSURLRequest *)request withDelegate:(id)delegate { - NSString *imageTag = [request.URL absoluteString]; + NSString *imageTag = request.URL.absoluteString; [self getImageForTag:imageTag withBlock:^(UIImage *image) { if (!image) { NSError *error = RCTErrorWithMessage([NSString stringWithFormat:@"Invalid imageTag: %@", imageTag]); diff --git a/Libraries/Image/RCTImageView.m b/Libraries/Image/RCTImageView.m index f56b3d183..ddbd23d77 100644 --- a/Libraries/Image/RCTImageView.m +++ b/Libraries/Image/RCTImageView.m @@ -42,7 +42,7 @@ return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (void)updateImage { diff --git a/Libraries/LinkingIOS/RCTLinkingManager.m b/Libraries/LinkingIOS/RCTLinkingManager.m index 5a97f0a60..af1d41752 100644 --- a/Libraries/LinkingIOS/RCTLinkingManager.m +++ b/Libraries/LinkingIOS/RCTLinkingManager.m @@ -42,7 +42,7 @@ RCT_EXPORT_MODULE() sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { - NSDictionary *payload = @{@"url": [URL absoluteString]}; + NSDictionary *payload = @{@"url": URL.absoluteString}; [[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification object:self userInfo:payload]; @@ -52,7 +52,7 @@ RCT_EXPORT_MODULE() - (void)handleOpenURLNotification:(NSNotification *)notification { [_bridge.eventDispatcher sendDeviceEventWithName:@"openURL" - body:[notification userInfo]]; + body:notification.userInfo]; } RCT_EXPORT_METHOD(openURL:(NSURL *)URL) @@ -72,7 +72,7 @@ RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL - (NSDictionary *)constantsToExport { NSURL *initialURL = _bridge.launchOptions[UIApplicationLaunchOptionsURLKey]; - return @{@"initialURL": RCTNullIfNil([initialURL absoluteString])}; + return @{@"initialURL": RCTNullIfNil(initialURL.absoluteString)}; } @end diff --git a/Libraries/Network/RCTDownloadTask.m b/Libraries/Network/RCTDownloadTask.m index f86b4b990..e523f1606 100644 --- a/Libraries/Network/RCTDownloadTask.m +++ b/Libraries/Network/RCTDownloadTask.m @@ -51,7 +51,7 @@ _uploadProgressBlock = nil; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (void)cancel { diff --git a/Libraries/Network/RCTHTTPRequestHandler.m b/Libraries/Network/RCTHTTPRequestHandler.m index 37165cfff..e1ad88ab1 100644 --- a/Libraries/Network/RCTHTTPRequestHandler.m +++ b/Libraries/Network/RCTHTTPRequestHandler.m @@ -47,7 +47,7 @@ RCT_EXPORT_MODULE() - (BOOL)canHandleRequest:(NSURLRequest *)request { - return [@[@"http", @"https", @"file"] containsObject:[request.URL.scheme lowercaseString]]; + return [@[@"http", @"https", @"file"] containsObject:request.URL.scheme.lowercaseString]; } - (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request diff --git a/Libraries/Network/RCTNetworking.m b/Libraries/Network/RCTNetworking.m index cbd8ebbfc..4853beff8 100644 --- a/Libraries/Network/RCTNetworking.m +++ b/Libraries/Network/RCTNetworking.m @@ -88,7 +88,7 @@ static NSString *RCTGenerateFormBoundary() NSMutableDictionary *headers = [parts[0][@"headers"] mutableCopy]; NSString *partContentType = result[@"contentType"]; if (partContentType != nil) { - [headers setObject:partContentType forKey:@"content-type"]; + headers[@"content-type"] = partContentType; } [headers enumerateKeysAndObjectsUsingBlock:^(NSString *parameterKey, NSString *parameterValue, BOOL *stop) { [multipartBody appendData:[[NSString stringWithFormat:@"%@: %@\r\n", parameterKey, parameterValue] @@ -142,7 +142,7 @@ RCT_EXPORT_MODULE() { NSURL *URL = [RCTConvert NSURL:query[@"url"]]; // this is marked as nullable in JS, but should not be null NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; - request.HTTPMethod = [[RCTConvert NSString:RCTNilIfNull(query[@"method"])] uppercaseString] ?: @"GET"; + request.HTTPMethod = [RCTConvert NSString:RCTNilIfNull(query[@"method"])].uppercaseString ?: @"GET"; request.allHTTPHeaderFields = [RCTConvert NSDictionary:query[@"headers"]]; NSDictionary *data = [RCTConvert NSDictionary:RCTNilIfNull(query[@"data"])]; @@ -161,7 +161,7 @@ RCT_EXPORT_MODULE() // Gzip the request body if ([request.allHTTPHeaderFields[@"Content-Encoding"] isEqualToString:@"gzip"]) { request.HTTPBody = RCTGzipData(request.HTTPBody, -1 /* default */); - [request setValue:[@(request.HTTPBody.length) description] forHTTPHeaderField:@"Content-Length"]; + [request setValue:(@(request.HTTPBody.length)).description forHTTPHeaderField:@"Content-Length"]; } block(request); @@ -195,7 +195,7 @@ RCT_EXPORT_MODULE() return NSOrderedSame; } }]; - id handler = [handlers lastObject]; + id handler = handlers.lastObject; if (!handler) { RCTLogError(@"No suitable request handler found for %@", request.URL); } diff --git a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m index 3f187b171..fda9980f9 100644 --- a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m +++ b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m @@ -108,13 +108,13 @@ RCT_EXPORT_MODULE() - (void)handleRemoteNotificationReceived:(NSNotification *)notification { [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationReceived" - body:[notification userInfo]]; + body:notification.userInfo]; } - (void)handleRemoteNotificationsRegistered:(NSNotification *)notification { [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationsRegistered" - body:[notification userInfo]]; + body:notification.userInfo]; } /** @@ -175,7 +175,7 @@ RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback) { NSUInteger types = 0; if ([UIApplication instancesRespondToSelector:@selector(currentUserNotificationSettings)]) { - types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types]; + types = [[UIApplication sharedApplication] currentUserNotificationSettings].types; } else { #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 diff --git a/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.m b/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.m index e38c6e4e8..0bd83ba3b 100644 --- a/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.m +++ b/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.m @@ -65,7 +65,7 @@ (CGBitmapInfo)kCGImageAlphaPremultipliedLast ); - CGFloat scaleFactor = [[UIScreen mainScreen] scale]; + CGFloat scaleFactor = [UIScreen mainScreen].scale; CGContextScaleCTM(referenceImageContext, scaleFactor, scaleFactor); CGContextScaleCTM(imageContext, scaleFactor, scaleFactor); diff --git a/Libraries/RCTTest/RCTTestModule.m b/Libraries/RCTTest/RCTTestModule.m index 9ef60c611..3ad89b827 100644 --- a/Libraries/RCTTest/RCTTestModule.m +++ b/Libraries/RCTTest/RCTTestModule.m @@ -44,7 +44,7 @@ RCT_EXPORT_METHOD(verifySnapshot:(RCTResponseSenderBlock)callback) [_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) { NSString *testName = NSStringFromSelector(_testSelector); - _snapshotCounter[testName] = [@([_snapshotCounter[testName] integerValue] + 1) stringValue]; + _snapshotCounter[testName] = (@([_snapshotCounter[testName] integerValue] + 1)).stringValue; NSError *error = nil; BOOL success = [_controller compareSnapshotOfView:_view diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index eed38cb38..372858ac9 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -55,7 +55,7 @@ return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (void)setRecordMode:(BOOL)recordMode { @@ -109,7 +109,7 @@ RCT_NOT_IMPLEMENTED(-init) [vc.view addSubview:rootView]; // Add as subview so it doesn't get resized NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; - while ([date timeIntervalSinceNow] > 0 && testModule.status == RCTTestStatusPending && error == nil) { + while (date.timeIntervalSinceNow > 0 && testModule.status == RCTTestStatusPending && error == nil) { [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; } diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index 49cc35901..b9c1ff2e7 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -34,8 +34,8 @@ static css_dim_t RCTMeasure(void *context, float width) { RCTShadowText *shadowText = (__bridge RCTShadowText *)context; NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width]; - NSLayoutManager *layoutManager = [textStorage.layoutManagers firstObject]; - NSTextContainer *textContainer = [layoutManager.textContainers firstObject]; + NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject; + NSTextContainer *textContainer = layoutManager.textContainers.firstObject; CGSize computedSize = [layoutManager usedRectForTextContainer:textContainer].size; css_dim_t result; @@ -190,7 +190,7 @@ static css_dim_t RCTMeasure(void *context, float width) [attributedString appendAttributedString:[shadowText _attributedStringWithFontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight fontStyle:fontStyle letterSpacing:letterSpacing useBackgroundColor:YES]]; } else if ([child isKindOfClass:[RCTShadowRawText class]]) { RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child; - [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[shadowRawText text] ?: @""]]; + [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]]; } else { RCTLogError(@" can't have any children except or raw strings"); } @@ -225,7 +225,7 @@ static css_dim_t RCTMeasure(void *context, float width) - (void)_addAttribute:(NSString *)attribute withValue:(id)attributeValue toAttributedString:(NSMutableAttributedString *)attributedString { - [attributedString enumerateAttribute:attribute inRange:NSMakeRange(0, [attributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { + [attributedString enumerateAttribute:attribute inRange:NSMakeRange(0, attributedString.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { if (!value && attributeValue) { [attributedString addAttribute:attribute value:attributeValue range:range]; } @@ -249,10 +249,10 @@ static css_dim_t RCTMeasure(void *context, float width) } // check for lineHeight on each of our children, update the max as we go (in self.lineHeight) - [attributedString enumerateAttribute:NSParagraphStyleAttributeName inRange:NSMakeRange(0, [attributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { + [attributedString enumerateAttribute:NSParagraphStyleAttributeName inRange:(NSRange){0, attributedString.length} options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { if (value) { NSParagraphStyle *paragraphStyle = (NSParagraphStyle *)value; - CGFloat maximumLineHeight = round([paragraphStyle maximumLineHeight] / self.fontSizeMultiplier); + CGFloat maximumLineHeight = round(paragraphStyle.maximumLineHeight / self.fontSizeMultiplier); if (maximumLineHeight > self.lineHeight) { self.lineHeight = maximumLineHeight; } @@ -305,13 +305,13 @@ static css_dim_t RCTMeasure(void *context, float width) - (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex { [super insertReactSubview:subview atIndex:atIndex]; - [self cssNode]->children_count = 0; + self.cssNode->children_count = 0; } - (void)removeReactSubview:(RCTShadowView *)subview { [super removeReactSubview:subview]; - [self cssNode]->children_count = 0; + self.cssNode->children_count = 0; } - (void)setBackgroundColor:(UIColor *)backgroundColor @@ -348,7 +348,7 @@ RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection) _allowFontScaling = allowFontScaling; for (RCTShadowView *child in [self reactSubviews]) { if ([child isKindOfClass:[RCTShadowText class]]) { - [(RCTShadowText *)child setAllowFontScaling:allowFontScaling]; + ((RCTShadowText *)child).allowFontScaling = allowFontScaling; } } [self dirtyText]; @@ -359,7 +359,7 @@ RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection) _fontSizeMultiplier = fontSizeMultiplier; for (RCTShadowView *child in [self reactSubviews]) { if ([child isKindOfClass:[RCTShadowText class]]) { - [(RCTShadowText *)child setFontSizeMultiplier:fontSizeMultiplier]; + ((RCTShadowText *)child).fontSizeMultiplier = fontSizeMultiplier; } } [self dirtyText]; diff --git a/Libraries/Text/RCTText.m b/Libraries/Text/RCTText.m index ae244c574..47b7de6a5 100644 --- a/Libraries/Text/RCTText.m +++ b/Libraries/Text/RCTText.m @@ -75,8 +75,8 @@ - (void)drawRect:(CGRect)rect { - NSLayoutManager *layoutManager = [_textStorage.layoutManagers firstObject]; - NSTextContainer *textContainer = [layoutManager.textContainers firstObject]; + NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject; + NSTextContainer *textContainer = layoutManager.textContainers.firstObject; CGRect textFrame = UIEdgeInsetsInsetRect(self.bounds, _contentInset); NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer]; @@ -119,8 +119,8 @@ NSNumber *reactTag = self.reactTag; CGFloat fraction; - NSLayoutManager *layoutManager = [_textStorage.layoutManagers firstObject]; - NSTextContainer *textContainer = [layoutManager.textContainers firstObject]; + NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject; + NSTextContainer *textContainer = layoutManager.textContainers.firstObject; NSUInteger characterIndex = [layoutManager characterIndexForPoint:point inTextContainer:textContainer fractionOfDistanceBetweenInsertionPoints:&fraction]; diff --git a/Libraries/Text/RCTTextField.m b/Libraries/Text/RCTTextField.m index a99771153..a75a268e9 100644 --- a/Libraries/Text/RCTTextField.m +++ b/Libraries/Text/RCTTextField.m @@ -36,15 +36,15 @@ return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)setText:(NSString *)text { NSInteger eventLag = _nativeEventCount - _mostRecentEventCount; if (eventLag == 0 && ![text isEqualToString:self.text]) { UITextRange *selection = self.selectedTextRange; - [super setText:text]; + super.text = text; self.selectedTextRange = selection; // maintain cursor position/selection - this is robust to out of bounds } else if (eventLag > RCTTextUpdateLagWarningThreshold) { RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, eventLag); diff --git a/Libraries/Text/RCTTextManager.m b/Libraries/Text/RCTTextManager.m index 92d9eb498..f7150b46b 100644 --- a/Libraries/Text/RCTTextManager.m +++ b/Libraries/Text/RCTTextManager.m @@ -66,12 +66,12 @@ RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL) } NSMutableArray *queue = [NSMutableArray arrayWithObject:rootView]; - for (NSInteger i = 0; i < [queue count]; i++) { + for (NSInteger i = 0; i < queue.count; i++) { RCTShadowView *shadowView = queue[i]; RCTAssert([shadowView isTextDirty], @"Don't process any nodes that don't have dirty text"); if ([shadowView isKindOfClass:[RCTShadowText class]]) { - [(RCTShadowText *)shadowView setFontSizeMultiplier:self.bridge.accessibilityManager.multiplier]; + ((RCTShadowText *)shadowView).fontSizeMultiplier = self.bridge.accessibilityManager.multiplier; [(RCTShadowText *)shadowView recomputeText]; } else if ([shadowView isKindOfClass:[RCTShadowRawText class]]) { RCTLogError(@"Raw text cannot be used outside of a tag. Not rendering string: '%@'", diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m index 337e4463a..bcae5fe0a 100644 --- a/Libraries/Text/RCTTextView.m +++ b/Libraries/Text/RCTTextView.m @@ -41,8 +41,8 @@ return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)updateFrames { @@ -166,7 +166,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) NSInteger eventLag = _nativeEventCount - _mostRecentEventCount; if (eventLag == 0 && ![text isEqualToString:_textView.text]) { UITextRange *selection = _textView.selectedTextRange; - [_textView setText:text]; + _textView.text = text; [self _setPlaceholderVisibility]; _textView.selectedTextRange = selection; // maintain cursor position/selection - this is robust to out of bounds } else if (eventLag > RCTTextUpdateLagWarningThreshold) { diff --git a/Libraries/WebSocket/RCTSRWebSocket.h b/Libraries/WebSocket/RCTSRWebSocket.h index ccaa46455..c185daca9 100644 --- a/Libraries/WebSocket/RCTSRWebSocket.h +++ b/Libraries/WebSocket/RCTSRWebSocket.h @@ -17,14 +17,14 @@ #import #import -typedef enum { +typedef NS_ENUM(unsigned int, RCTSRReadyState) { RCTSR_CONNECTING = 0, RCTSR_OPEN = 1, RCTSR_CLOSING = 2, RCTSR_CLOSED = 3, -} RCTSRReadyState; +}; -typedef enum RCTSRStatusCode : NSInteger { +typedef NS_ENUM(NSInteger, RCTSRStatusCode) { RCTSRStatusCodeNormal = 1000, RCTSRStatusCodeGoingAway = 1001, RCTSRStatusCodeProtocolError = 1002, @@ -35,7 +35,7 @@ typedef enum RCTSRStatusCode : NSInteger { RCTSRStatusCodeInvalidUTF8 = 1007, RCTSRStatusCodePolicyViolated = 1008, RCTSRStatusCodeMessageTooBig = 1009, -} RCTSRStatusCode; +}; @class RCTSRWebSocket; diff --git a/Libraries/WebSocket/RCTSRWebSocket.m b/Libraries/WebSocket/RCTSRWebSocket.m index 2b6f63523..44676b058 100644 --- a/Libraries/WebSocket/RCTSRWebSocket.m +++ b/Libraries/WebSocket/RCTSRWebSocket.m @@ -53,14 +53,14 @@ static inline void RCTSRFastLog(NSString *format, ...); @interface NSData (RCTSRWebSocket) -- (NSString *)stringBySHA1ThenBase64Encoding; +@property (nonatomic, readonly, copy) NSString *stringBySHA1ThenBase64Encoding; @end @interface NSString (RCTSRWebSocket) -- (NSString *)stringBySHA1ThenBase64Encoding; +@property (nonatomic, readonly, copy) NSString *stringBySHA1ThenBase64Encoding; @end @@ -69,7 +69,7 @@ static inline void RCTSRFastLog(NSString *format, ...); // The origin isn't really applicable for a native application. // So instead, just map ws -> http and wss -> https. -- (NSString *)RCTSR_origin; +@property (nonatomic, readonly, copy) NSString *RCTSR_origin; @end @@ -259,7 +259,7 @@ static __strong NSData *CRLFCRLF; return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (instancetype)initWithURLRequest:(NSURLRequest *)request; { @@ -511,7 +511,7 @@ RCT_NOT_IMPLEMENTED(-init) [_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel]; // If we're using pinned certs, don't validate the certificate chain - if ([_urlRequest RCTSR_SSLPinnedCertificates].count) { + if (_urlRequest.RCTSR_SSLPinnedCertificates.count) { [SSLOptions setValue:@NO forKey:(__bridge id)kCFStreamSSLValidatesCertificateChain]; } @@ -998,7 +998,7 @@ static const uint8_t RCTSRPayloadLenMask = 0x7F; - (void)_readFrameNew; { dispatch_async(_workQueue, ^{ - [_currentFrameData setLength:0]; + _currentFrameData.length = 0; _currentFrameOpcode = 0; _currentFrameCount = 0; @@ -1253,7 +1253,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32; [self closeWithCode:RCTSRStatusCodeMessageTooBig reason:@"Message too big"]; return; } - uint8_t *frame_buffer = (uint8_t *)[frame mutableBytes]; + uint8_t *frame_buffer = (uint8_t *)frame.mutableBytes; // set fin frame_buffer[0] = RCTSRFinMask | opcode; @@ -1318,7 +1318,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32; { if (_secure && !_pinnedCertFound && (eventCode == NSStreamEventHasBytesAvailable || eventCode == NSStreamEventHasSpaceAvailable)) { - NSArray *sslCerts = [_urlRequest RCTSR_SSLPinnedCertificates]; + NSArray *sslCerts = _urlRequest.RCTSR_SSLPinnedCertificates; if (sslCerts) { SecTrustRef secTrust = (__bridge SecTrustRef)[aStream propertyForKey:(__bridge id)kCFStreamPropertySSLPeerTrust]; if (secTrust) { @@ -1366,11 +1366,11 @@ static const size_t RCTSRFrameHeaderOverhead = 32; } case NSStreamEventErrorOccurred: { - RCTSRFastLog(@"NSStreamEventErrorOccurred %@ %@", aStream, [[aStream streamError] copy]); + RCTSRFastLog(@"NSStreamEventErrorOccurred %@ %@", aStream, [aStream.streamError copy]); // TODO: specify error better! [self _failWithError:aStream.streamError]; _readBufferOffset = 0; - [_readBuffer setLength:0]; + _readBuffer.length = 0; break; } @@ -1475,7 +1475,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32; { RCTSRIOConsumer *consumer = nil; if (_bufferedConsumers.count) { - consumer = [_bufferedConsumers lastObject]; + consumer = _bufferedConsumers.lastObject; [_bufferedConsumers removeLastObject]; } else { consumer = [RCTSRIOConsumer new]; @@ -1522,7 +1522,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32; - (NSString *)RCTSR_origin; { - NSString *scheme = [self.scheme lowercaseString]; + NSString *scheme = self.scheme.lowercaseString; if ([scheme isEqualToString:@"wss"]) { scheme = @"https"; diff --git a/Libraries/WebSocket/RCTWebSocketExecutor.m b/Libraries/WebSocket/RCTWebSocketExecutor.m index bd9600d3c..815ab56d1 100644 --- a/Libraries/WebSocket/RCTWebSocketExecutor.m +++ b/Libraries/WebSocket/RCTWebSocketExecutor.m @@ -152,7 +152,7 @@ RCT_EXPORT_MODULE() { NSDictionary *message = @{ @"method": @"executeApplicationScript", - @"url": RCTNullIfNil([URL absoluteString]), + @"url": RCTNullIfNil(URL.absoluteString), @"inject": _injectedObjects, }; [self sendMessage:message waitForReply:^(NSError *error, NSDictionary *reply) { diff --git a/Libraries/WebSocket/RCTWebSocketManager.m b/Libraries/WebSocket/RCTWebSocketManager.m index 28d6c3ed0..039dd7f22 100644 --- a/Libraries/WebSocket/RCTWebSocketManager.m +++ b/Libraries/WebSocket/RCTWebSocketManager.m @@ -98,7 +98,7 @@ RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID) - (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error { [_bridge.eventDispatcher sendDeviceEventWithName:@"websocketFailed" body:@{ - @"message":[error localizedDescription], + @"message":error.localizedDescription, @"id": webSocket.reactTag }]; } diff --git a/React/Base/RCTAssert.m b/React/Base/RCTAssert.m index b3d729634..4c497614c 100644 --- a/React/Base/RCTAssert.m +++ b/React/Base/RCTAssert.m @@ -60,7 +60,7 @@ static RCTAssertFunction RCTGetLocalAssertFunction() { NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; NSArray *functionStack = threadDictionary[RCTAssertFunctionStack]; - RCTAssertFunction assertFunction = [functionStack lastObject]; + RCTAssertFunction assertFunction = functionStack.lastObject; if (assertFunction) { return assertFunction; } @@ -83,7 +83,7 @@ void RCTPerformBlockWithAssertFunction(void (^block)(void), RCTAssertFunction as NSString *RCTCurrentThreadName(void) { NSThread *thread = [NSThread currentThread]; - NSString *threadName = [thread isMainThread] ? @"main" : thread.name; + NSString *threadName = thread.isMainThread ? @"main" : thread.name; if (threadName.length == 0) { const char *label = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL); if (label && strlen(label) > 0) { diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 7e447a5e7..47e868fae 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -118,7 +118,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); dispatch_group_t initModulesAndLoadSource = dispatch_group_create(); dispatch_group_enter(initModulesAndLoadSource); __block NSString *sourceCode; - [self loadSource:^(NSError *error, NSString *source) { + [self loadSource:^(__unused NSError *error, NSString *source) { sourceCode = source; dispatch_group_leave(initModulesAndLoadSource); }]; @@ -174,7 +174,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); RCTPerformanceLoggerEnd(RCTPLScriptDownload); if (error) { - NSArray *stack = [error userInfo][@"stack"]; + NSArray *stack = error.userInfo[@"stack"]; if (stack) { [self.redBox showErrorMessage:error.localizedDescription withStack:stack]; @@ -353,7 +353,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); } -RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL +RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleURL moduleProvider:(__unused RCTBridgeModuleProviderBlock)block launchOptions:(__unused NSDictionary *)launchOptions) @@ -634,7 +634,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL } for (NSUInteger fieldIndex = RCTBridgeFieldRequestModuleIDs; fieldIndex <= RCTBridgeFieldParamss; fieldIndex++) { - id field = [requestsArray objectAtIndex:fieldIndex]; + id field = requestsArray[fieldIndex]; if (![field isKindOfClass:[NSArray class]]) { RCTLogError(@"Field at index %zd in buffer must be an instance of NSArray, got %@", fieldIndex, NSStringFromClass([field class])); return; @@ -647,7 +647,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL NSArray *methodIDs = requestsArray[RCTBridgeFieldMethodIDs]; NSArray *paramsArrays = requestsArray[RCTBridgeFieldParamss]; - NSUInteger numRequests = [moduleIDs count]; + NSUInteger numRequests = moduleIDs.count; if (RCT_DEBUG && (numRequests != methodIDs.count || numRequests != paramsArrays.count)) { RCTLogError(@"Invalid data message - all must be length: %zd", numRequests); @@ -761,7 +761,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink]; for (RCTModuleData *moduleData in _frameUpdateObservers) { id observer = (id)moduleData.instance; - if (![observer respondsToSelector:@selector(isPaused)] || ![observer isPaused]) { + if (![observer respondsToSelector:@selector(isPaused)] || !observer.paused) { RCT_IF_DEV(NSString *name = [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp];) RCTProfileBeginFlowEvent(); diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 486b9de73..543012602 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -75,7 +75,7 @@ NSString *RCTBridgeModuleNameForClass(Class cls) if ([cls respondsToSelector:NSSelectorFromString(@"moduleName")]) { name = [cls valueForKey:@"moduleName"]; } - if ([name length] == 0) { + if (name.length == 0) { name = NSStringFromClass(cls); } if ([name hasPrefix:@"RK"]) { @@ -192,7 +192,7 @@ static RCTBridge *RCTCurrentBridgeInstance = nil; return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (void)dealloc { diff --git a/React/Base/RCTCache.m b/React/Base/RCTCache.m index b61922ae4..473dcd406 100644 --- a/React/Base/RCTCache.m +++ b/React/Base/RCTCache.m @@ -52,7 +52,7 @@ NSLock *_lock; } -- (id)init +- (instancetype)init { if ((self = [super init])) { @@ -103,7 +103,7 @@ - (NSUInteger)count { - return [_cache count]; + return _cache.count; } - (void)cleanUp:(BOOL)keepEntries @@ -162,7 +162,7 @@ [_lock lock]; if (_delegateRespondsToShouldEvictObject || _delegateRespondsToWillEvictObject) { - NSArray *keys = [_cache allKeys]; + NSArray *keys = _cache.allKeys; if (_delegateRespondsToShouldEvictObject) { //sort, oldest first (in case we want to use that information in our eviction test) @@ -202,7 +202,7 @@ - (void)resequence { //sort, oldest first - NSArray *entries = [[_cache allValues] sortedArrayUsingComparator:^NSComparisonResult(RCTCacheEntry *entry1, RCTCacheEntry *entry2) { + NSArray *entries = [_cache.allValues sortedArrayUsingComparator:^NSComparisonResult(RCTCacheEntry *entry1, RCTCacheEntry *entry2) { return (NSComparisonResult)MIN(1, MAX(-1, entry1.sequenceNumber - entry2.sequenceNumber)); }]; diff --git a/React/Base/RCTConvert.h b/React/Base/RCTConvert.h index cf7f056e3..cad32b860 100644 --- a/React/Base/RCTConvert.h +++ b/React/Base/RCTConvert.h @@ -80,10 +80,10 @@ typedef NSURL RCTFileURL; + (CGAffineTransform)CGAffineTransform:(id)json; + (UIColor *)UIColor:(id)json; -+ (CGColorRef)CGColor:(id)json; ++ (CGColorRef)CGColor:(id)json CF_RETURNS_NOT_RETAINED; + (UIImage *)UIImage:(id)json; -+ (CGImageRef)CGImage:(id)json; ++ (CGImageRef)CGImage:(id)json CF_RETURNS_NOT_RETAINED; + (UIFont *)UIFont:(id)json; + (UIFont *)UIFont:(UIFont *)font withSize:(id)json; diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index c0d0ac0e2..8141b1386 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -95,13 +95,13 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod } // Assume that it's a local path - path = [path stringByRemovingPercentEncoding]; + path = path.stringByRemovingPercentEncoding; if ([path hasPrefix:@"~"]) { // Path is inside user directory - path = [path stringByExpandingTildeInPath]; - } else if (![path isAbsolutePath]) { + path = path.stringByExpandingTildeInPath; + } else if (!path.absolutePath) { // Assume it's a resource path - path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:path]; + path = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:path]; } return [NSURL fileURLWithPath:path]; } @@ -120,7 +120,7 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod + (RCTFileURL *)RCTFileURL:(id)json { NSURL *fileURL = [self NSURL:json]; - if (![fileURL isFileURL]) { + if (!fileURL.fileURL) { RCTLogError(@"URI must be a local file, '%@' isn't.", fileURL); return nil; } @@ -168,8 +168,8 @@ NSNumber *RCTConvertEnumValue(const char *typeName, NSDictionary *mapping, NSNum return defaultValue; } if ([json isKindOfClass:[NSNumber class]]) { - NSArray *allValues = [mapping allValues]; - if ([[mapping allValues] containsObject:json] || [json isEqual:defaultValue]) { + NSArray *allValues = mapping.allValues; + if ([mapping.allValues containsObject:json] || [json isEqual:defaultValue]) { return json; } RCTLogError(@"Invalid %s '%@'. should be one of: %@", typeName, json, allValues); @@ -195,7 +195,7 @@ NSNumber *RCTConvertMultiEnumValue(const char *typeName, NSDictionary *mapping, long long result = 0; for (id arrayElement in json) { NSNumber *value = RCTConvertEnumValue(typeName, mapping, defaultValue, arrayElement); - result |= [value longLongValue]; + result |= value.longLongValue; } return @(result); } @@ -582,7 +582,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[ if ([colorString hasPrefix:@"#"]) { uint32_t redInt = 0, greenInt = 0, blueInt = 0; if (colorString.length == 4) { // 3 digit hex - sscanf([colorString UTF8String], "#%01x%01x%01x", &redInt, &greenInt, &blueInt); + sscanf(colorString.UTF8String, "#%01x%01x%01x", &redInt, &greenInt, &blueInt); // expand to 6 digit hex components.rgb.r = redInt / 15.0; components.rgb.g = greenInt / 15.0; @@ -694,10 +694,10 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[ } NSURL *URL = [self NSURL:path]; - NSString *scheme = [URL.scheme lowercaseString]; + NSString *scheme = URL.scheme.lowercaseString; if (path && [scheme isEqualToString:@"file"]) { if (RCT_DEBUG || [NSThread currentThread] == [NSThread mainThread]) { - if ([URL.path hasPrefix:[[NSBundle mainBundle] resourcePath]]) { + if ([URL.path hasPrefix:[NSBundle mainBundle].resourcePath]) { // Image may reside inside a .car file, in which case we have no choice // but to use +[UIImage imageNamed] - but this method isn't thread safe static NSMutableDictionary *XCAssetMap = nil; @@ -722,7 +722,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[ if (!image) { // Attempt to load from the file system - if ([path pathExtension].length == 0) { + if (path.pathExtension.length == 0) { path = [path stringByAppendingPathExtension:@"png"]; } image = [UIImage imageWithContentsOfFile:path]; diff --git a/React/Base/RCTEventDispatcher.m b/React/Base/RCTEventDispatcher.m index 5e6ac6b4d..af5f30eed 100644 --- a/React/Base/RCTEventDispatcher.m +++ b/React/Base/RCTEventDispatcher.m @@ -29,7 +29,7 @@ NSString *RCTNormalizeInputEventName(NSString *eventName) static NSNumber *RCTGetEventID(id event) { return @( - [event.viewTag intValue] | + event.viewTag.intValue | (((uint64_t)event.eventName.hash & 0xFFFF) << 32) | (((uint64_t)event.coalescingKey) << 48) ); @@ -57,7 +57,7 @@ static NSNumber *RCTGetEventID(id event) return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (uint16_t)coalescingKey { diff --git a/React/Base/RCTFPSGraph.m b/React/Base/RCTFPSGraph.m index c5580a2f4..1cd33432f 100644 --- a/React/Base/RCTFPSGraph.m +++ b/React/Base/RCTFPSGraph.m @@ -56,8 +56,8 @@ return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)dealloc { @@ -74,8 +74,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) CGFloat left = _position & RCTFPSGraphPositionLeft ? 0 : _length; 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]; + graph.backgroundColor = [color colorWithAlphaComponent:0.2].CGColor; + graph.fillColor = color.CGColor; return graph; } diff --git a/React/Base/RCTFrameUpdate.m b/React/Base/RCTFrameUpdate.m index 2d9f63825..dbbcc4a32 100644 --- a/React/Base/RCTFrameUpdate.m +++ b/React/Base/RCTFrameUpdate.m @@ -15,7 +15,7 @@ @implementation RCTFrameUpdate -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (instancetype)initWithDisplayLink:(CADisplayLink *)displayLink { diff --git a/React/Base/RCTJavaScriptLoader.m b/React/Base/RCTJavaScriptLoader.m index 021d9a065..0aa73c68d 100755 --- a/React/Base/RCTJavaScriptLoader.m +++ b/React/Base/RCTJavaScriptLoader.m @@ -16,7 +16,7 @@ @implementation RCTJavaScriptLoader -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) + (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(RCTSourceLoadBlock)onComplete { @@ -24,7 +24,7 @@ RCT_NOT_IMPLEMENTED(-init) scriptURL = [RCTConvert NSURL:scriptURL.absoluteString]; if (!scriptURL || - ([scriptURL isFileURL] && ![[NSFileManager defaultManager] fileExistsAtPath:scriptURL.path])) { + (scriptURL.fileURL && ![[NSFileManager defaultManager] fileExistsAtPath:scriptURL.path])) { NSError *error = [NSError errorWithDomain:@"JavaScriptLoader" code:1 userInfo:@{ NSLocalizedDescriptionKey: scriptURL ? [NSString stringWithFormat:@"Script at '%@' could not be found.", scriptURL] : @"No script URL provided" }]; @@ -37,11 +37,11 @@ RCT_NOT_IMPLEMENTED(-init) // Handle general request errors if (error) { - if ([[error domain] isEqualToString:NSURLErrorDomain]) { - NSString *desc = [@"Could not connect to development server. Ensure node server is running and available on the same network - run 'npm start' from react-native root\n\nURL: " stringByAppendingString:[scriptURL absoluteString]]; + if ([error.domain isEqualToString:NSURLErrorDomain]) { + NSString *desc = [@"Could not connect to development server. Ensure node server is running and available on the same network - run 'npm start' from react-native root\n\nURL: " stringByAppendingString:scriptURL.absoluteString]; NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: desc, - NSLocalizedFailureReasonErrorKey: [error localizedDescription], + NSLocalizedFailureReasonErrorKey: error.localizedDescription, NSUnderlyingErrorKey: error, }; error = [NSError errorWithDomain:@"JSServer" @@ -63,7 +63,7 @@ RCT_NOT_IMPLEMENTED(-init) NSString *rawText = [[NSString alloc] initWithData:data encoding:encoding]; // Handle HTTP errors - if ([response isKindOfClass:[NSHTTPURLResponse class]] && [(NSHTTPURLResponse *)response statusCode] != 200) { + if ([response isKindOfClass:[NSHTTPURLResponse class]] && ((NSHTTPURLResponse *)response).statusCode != 200) { NSDictionary *userInfo; NSDictionary *errorDetails = RCTJSONParse(rawText, nil); if ([errorDetails isKindOfClass:[NSDictionary class]] && @@ -84,7 +84,7 @@ RCT_NOT_IMPLEMENTED(-init) userInfo = @{NSLocalizedDescriptionKey: rawText}; } error = [NSError errorWithDomain:@"JSServer" - code:[(NSHTTPURLResponse *)response statusCode] + code:((NSHTTPURLResponse *)response).statusCode userInfo:userInfo]; onComplete(error, nil); diff --git a/React/Base/RCTKeyCommands.m b/React/Base/RCTKeyCommands.m index d3b80ac55..36516bbc1 100644 --- a/React/Base/RCTKeyCommands.m +++ b/React/Base/RCTKeyCommands.m @@ -40,7 +40,7 @@ static BOOL RCTIsIOS8OrEarlier() return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (id)copyWithZone:(__unused NSZone *)zone { diff --git a/React/Base/RCTLog.m b/React/Base/RCTLog.m index 44b77ad2c..a8679da9e 100644 --- a/React/Base/RCTLog.m +++ b/React/Base/RCTLog.m @@ -116,7 +116,7 @@ static RCTLogFunction RCTGetLocalLogFunction() { NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; NSArray *functionStack = threadDictionary[RCTLogFunctionStack]; - RCTLogFunction logFunction = [functionStack lastObject]; + RCTLogFunction logFunction = functionStack.lastObject; if (logFunction) { return logFunction; } @@ -171,7 +171,7 @@ NSString *RCTFormatLog( [log appendFormat:@"[tid:%@]", RCTCurrentThreadName()]; if (fileName) { - fileName = [fileName lastPathComponent]; + fileName = fileName.lastPathComponent; if (lineNumber) { [log appendFormat:@"[%@:%@]", fileName, lineNumber]; } else { @@ -219,7 +219,7 @@ void _RCTLogFormat( NSRange addressRange = [frameSymbols rangeOfString:address]; NSString *methodName = [frameSymbols substringFromIndex:(addressRange.location + addressRange.length + 1)]; if (idx == 1) { - NSString *file = [[@(fileName) componentsSeparatedByString:@"/"] lastObject]; + NSString *file = [@(fileName) componentsSeparatedByString:@"/"].lastObject; [stack addObject:@{@"methodName": methodName, @"file": file, @"lineNumber": @(lineNumber)}]; } else { [stack addObject:@{@"methodName": methodName}]; diff --git a/React/Base/RCTModuleData.m b/React/Base/RCTModuleData.m index 3d492c8b2..dfc21ea3f 100644 --- a/React/Base/RCTModuleData.m +++ b/React/Base/RCTModuleData.m @@ -38,13 +38,12 @@ } // Must be done at init time due to race conditions - // Also, the queue setup isn't thread safe due ti static name cache - [self queue]; + (void)self.queue; } return self; } -RCT_NOT_IMPLEMENTED(-init); +RCT_NOT_IMPLEMENTED(- (instancetype)init); - (NSArray *)methods { @@ -101,7 +100,7 @@ RCT_NOT_IMPLEMENTED(-init); if (!_queue) { BOOL implementsMethodQueue = [_instance respondsToSelector:@selector(methodQueue)]; if (implementsMethodQueue) { - _queue = [_instance methodQueue]; + _queue = _instance.methodQueue; } if (!_queue) { diff --git a/React/Base/RCTModuleMap.m b/React/Base/RCTModuleMap.m index cd10c5b88..5491c1256 100644 --- a/React/Base/RCTModuleMap.m +++ b/React/Base/RCTModuleMap.m @@ -19,11 +19,11 @@ NSDictionary *_modulesByName; } -RCT_NOT_IMPLEMENTED(-init) -RCT_NOT_IMPLEMENTED(-initWithCoder:aDecoder) -RCT_NOT_IMPLEMENTED(-initWithObjects:(const id [])objects - forKeys:(const id [])keys - count:(NSUInteger)cnt) +RCT_NOT_IMPLEMENTED(- (instancetype)init) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithObjects:(const id [])objects + forKeys:(const id [])keys + count:(NSUInteger)cnt) - (instancetype)initWithDictionary:(NSDictionary *)modulesByName { diff --git a/React/Base/RCTModuleMethod.m b/React/Base/RCTModuleMethod.m index f9a493e26..2cb0ce476 100644 --- a/React/Base/RCTModuleMethod.m +++ b/React/Base/RCTModuleMethod.m @@ -60,7 +60,7 @@ static void RCTLogArgumentError(RCTModuleMethod *method, NSUInteger index, method->_JSMethodName, issue); } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) void RCTParseObjCMethodName(NSString **, NSArray **); void RCTParseObjCMethodName(NSString **objCMethodName, NSArray **arguments) @@ -154,7 +154,7 @@ void RCTParseObjCMethodName(NSString **objCMethodName, NSArray **arguments) NSMethodSignature *methodSignature = [_moduleClass instanceMethodSignatureForSelector:_selector]; RCTAssert(methodSignature, @"%@ is not a recognized Objective-C method.", objCMethodName); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature]; - [invocation setSelector:_selector]; + invocation.selector = _selector; [invocation retainArguments]; _invocation = invocation; @@ -234,8 +234,8 @@ void RCTParseObjCMethodName(NSString **objCMethodName, NSArray **arguments) NSMethodSignature *typeSignature = [RCTConvert methodSignatureForSelector:selector]; NSInvocation *typeInvocation = [NSInvocation invocationWithMethodSignature:typeSignature]; - [typeInvocation setSelector:selector]; - [typeInvocation setTarget:[RCTConvert class]]; + typeInvocation.selector = selector; + typeInvocation.target = [RCTConvert class]; [argumentBlocks addObject:^(__unused RCTBridge *bridge, NSUInteger index, id json) { void *returnValue = malloc(typeSignature.methodReturnLength); diff --git a/React/Base/RCTPerfStats.m b/React/Base/RCTPerfStats.m index 2f025a03b..13ea44f70 100644 --- a/React/Base/RCTPerfStats.m +++ b/React/Base/RCTPerfStats.m @@ -66,7 +66,7 @@ RCT_EXPORT_MODULE() - (void)show { - UIView *targetView = [[[[[UIApplication sharedApplication] delegate] window] rootViewController] view]; + UIView *targetView = [UIApplication sharedApplication].delegate.window.rootViewController.view; targetView.frame = (CGRect){ targetView.frame.origin, diff --git a/React/Base/RCTProfile.m b/React/Base/RCTProfile.m index 85d5a799a..86aab5652 100644 --- a/React/Base/RCTProfile.m +++ b/React/Base/RCTProfile.m @@ -289,7 +289,7 @@ void RCTProfileEndEvent( CHECK(); NSMutableArray *events = RCTProfileGetThreadEvents(); - NSArray *event = [events lastObject]; + NSArray *event = events.lastObject; [events removeLastObject]; if (!event) { diff --git a/React/Base/RCTRootView.m b/React/Base/RCTRootView.m index 1e8551e88..930aaa13c 100644 --- a/React/Base/RCTRootView.m +++ b/React/Base/RCTRootView.m @@ -44,7 +44,7 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat @property (nonatomic, readonly) BOOL contentHasAppeared; -- (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge; +- (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; @end @@ -104,8 +104,8 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat return [self initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)setBackgroundColor:(UIColor *)backgroundColor { @@ -237,7 +237,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge { - if ((self = [super init])) { + if ((self = [super initWithFrame:frame])) { _bridge = bridge; [self setUp]; self.frame = frame; @@ -246,6 +246,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) return self; } +RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder:(nonnull NSCoder *)aDecoder) + - (void)insertReactSubview:(id)subview atIndex:(NSInteger)atIndex { [super insertReactSubview:subview atIndex:atIndex]; diff --git a/React/Base/RCTSparseArray.m b/React/Base/RCTSparseArray.m index 236e64d17..1c67df644 100644 --- a/React/Base/RCTSparseArray.m +++ b/React/Base/RCTSparseArray.m @@ -117,7 +117,7 @@ - (NSString *)description { - return [[super description] stringByAppendingString:[_storage description]]; + return [super.description stringByAppendingString:_storage.description]; } @end diff --git a/React/Base/RCTTouchHandler.m b/React/Base/RCTTouchHandler.m index 3dd64bbdf..5c6333f21 100644 --- a/React/Base/RCTTouchHandler.m +++ b/React/Base/RCTTouchHandler.m @@ -60,7 +60,7 @@ return self; } -RCT_NOT_IMPLEMENTED(-initWithTarget:(id)target action:(SEL)action) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action) typedef NS_ENUM(NSInteger, RCTTouchEventType) { RCTTouchEventTypeStart, @@ -224,7 +224,7 @@ static BOOL RCTAnyTouchesChanged(NSSet *touches) { // If gesture just recognized, send all touches to JS as if they just began. if (self.state == UIGestureRecognizerStateBegan) { - [self _updateAndDispatchTouches:[_nativeTouches set] eventName:@"topTouchStart" originatingTime:0]; + [self _updateAndDispatchTouches:_nativeTouches.set eventName:@"topTouchStart" originatingTime:0]; // We store this flag separately from `state` because after a gesture is // recognized, its `state` changes immediately but its action (this diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 8f5875359..2fba55f00 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -171,7 +171,7 @@ id RCTJSONClean(id object) NSString *RCTMD5Hash(NSString *string) { - const char *str = [string UTF8String]; + const char *str = string.UTF8String; unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(str, (CC_LONG)strlen(str), result); diff --git a/React/Executors/RCTContextExecutor.m b/React/Executors/RCTContextExecutor.m index df3c232d5..e002d4b54 100644 --- a/React/Executors/RCTContextExecutor.m +++ b/React/Executors/RCTContextExecutor.m @@ -41,7 +41,7 @@ @property (nonatomic, assign, readonly) JSGlobalContextRef ctx; -- (instancetype)initWithJSContext:(JSGlobalContextRef)context; +- (instancetype)initWithJSContext:(JSGlobalContextRef)context NS_DESIGNATED_INITIALIZER; @end @@ -59,6 +59,8 @@ return self; } +RCT_NOT_IMPLEMENTED(-(instancetype)init) + - (BOOL)isValid { return _ctx != NULL; @@ -195,7 +197,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError) { @autoreleasepool { // copy thread name to pthread name - pthread_setname_np([[[NSThread currentThread] name] UTF8String]); + pthread_setname_np([NSThread currentThread].name.UTF8String); // Set up a dummy runloop source to avoid spinning CFRunLoopSourceContext noSpinCtx = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; @@ -204,7 +206,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError) CFRelease(noSpinSource); // run the run loop - while (kCFRunLoopRunStopped != CFRunLoopRunInMode(kCFRunLoopDefaultMode, [[NSDate distantFuture] timeIntervalSinceReferenceDate], NO)) { + while (kCFRunLoopRunStopped != CFRunLoopRunInMode(kCFRunLoopDefaultMode, ((NSDate *)[NSDate distantFuture]).timeIntervalSinceReferenceDate, NO)) { RCTAssert(NO, @"not reached assertion"); // runloop spun. that's bad. } } @@ -215,8 +217,8 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError) NSThread *javaScriptThread = [[NSThread alloc] initWithTarget:[self class] selector:@selector(runRunLoopThread) object:nil]; - [javaScriptThread setName:@"com.facebook.React.JavaScript"]; - [javaScriptThread setThreadPriority:[[NSThread mainThread] threadPriority]]; + javaScriptThread.name = @"com.facebook.React.JavaScript"; + javaScriptThread.threadPriority = [NSThread mainThread].threadPriority; [javaScriptThread start]; return [self initWithJavaScriptThread:javaScriptThread globalContextRef:NULL]; diff --git a/React/Executors/RCTWebViewExecutor.m b/React/Executors/RCTWebViewExecutor.m index 14c21e8b2..edc3846a0 100644 --- a/React/Executors/RCTWebViewExecutor.m +++ b/React/Executors/RCTWebViewExecutor.m @@ -58,7 +58,7 @@ RCT_EXPORT_MODULE() return self; } -- (id)init +- (instancetype)init { return [self initWithWebView:nil]; } diff --git a/React/Modules/RCTAccessibilityManager.m b/React/Modules/RCTAccessibilityManager.m index d016e6a01..12330c849 100644 --- a/React/Modules/RCTAccessibilityManager.m +++ b/React/Modules/RCTAccessibilityManager.m @@ -61,7 +61,7 @@ RCT_EXPORT_MODULE() selector:@selector(didReceiveNewContentSizeCategory:) name:UIContentSizeCategoryDidChangeNotification object:[UIApplication sharedApplication]]; - self.contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory]; + self.contentSizeCategory = [UIApplication sharedApplication].preferredContentSizeCategory; } return self; } diff --git a/React/Modules/RCTAlertManager.m b/React/Modules/RCTAlertManager.m index ea8cd9d90..261418b0d 100644 --- a/React/Modules/RCTAlertManager.m +++ b/React/Modules/RCTAlertManager.m @@ -90,7 +90,7 @@ RCT_EXPORT_METHOD(alertWithArgs:(NSDictionary *)args if (button.count != 1) { RCTLogError(@"Button definitions should have exactly one key."); } - NSString *buttonKey = [button.allKeys firstObject]; + NSString *buttonKey = button.allKeys.firstObject; NSString *buttonTitle = [button[buttonKey] description]; [alertView addButtonWithTitle:buttonTitle]; if ([buttonKey isEqualToString: @"cancel"]) { diff --git a/React/Modules/RCTAppState.m b/React/Modules/RCTAppState.m index cf8f95910..feb4afaf4 100644 --- a/React/Modules/RCTAppState.m +++ b/React/Modules/RCTAppState.m @@ -25,7 +25,7 @@ static NSString *RCTCurrentAppBackgroundState() }; }); - return states[@([[UIApplication sharedApplication] applicationState])] ?: @"unknown"; + return states[@([UIApplication sharedApplication].applicationState)] ?: @"unknown"; } @implementation RCTAppState diff --git a/React/Modules/RCTAsyncLocalStorage.m b/React/Modules/RCTAsyncLocalStorage.m index 262b578be..1ef86eb84 100644 --- a/React/Modules/RCTAsyncLocalStorage.m +++ b/React/Modules/RCTAsyncLocalStorage.m @@ -66,7 +66,7 @@ static NSString *RCTGetStorageDirectory() static NSString *storageDirectory = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - storageDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; + storageDirectory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject; storageDirectory = [storageDirectory stringByAppendingPathComponent:RCTStorageDirectory]; }); return storageDirectory; @@ -390,7 +390,7 @@ RCT_EXPORT_METHOD(getAllKeys:(RCTResponseSenderBlock)callback) if (errorOut) { callback(@[errorOut, (id)kCFNull]); } else { - callback(@[(id)kCFNull, [_manifest allKeys]]); + callback(@[(id)kCFNull, _manifest.allKeys]); } } diff --git a/React/Modules/RCTDevLoadingView.m b/React/Modules/RCTDevLoadingView.m index d9e30b667..8968c07f1 100644 --- a/React/Modules/RCTDevLoadingView.m +++ b/React/Modules/RCTDevLoadingView.m @@ -61,7 +61,7 @@ RCT_EXPORT_MODULE() _showDate = [NSDate date]; if (!_window && !RCTRunningInTestEnvironment()) { - CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width; + CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; _window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 22)]; _window.backgroundColor = [UIColor blackColor]; _window.windowLevel = UIWindowLevelStatusBar + 1; @@ -76,10 +76,10 @@ RCT_EXPORT_MODULE() } NSString *source; - if ([URL isFileURL]) { + if (URL.fileURL) { source = @"pre-bundled file"; } else { - source = [NSString stringWithFormat:@"%@:%@", [URL host], [URL port]]; + source = [NSString stringWithFormat:@"%@:%@", URL.host, URL.port]; } _label.text = [NSString stringWithFormat:@"Loading from %@...", source]; diff --git a/React/Modules/RCTDevMenu.m b/React/Modules/RCTDevMenu.m index 08d2ebe26..56ef7dfd4 100644 --- a/React/Modules/RCTDevMenu.m +++ b/React/Modules/RCTDevMenu.m @@ -64,7 +64,7 @@ static NSString *const RCTDevMenuSettingsKey = @"RCTDevMenu"; return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) @end @@ -210,7 +210,7 @@ RCT_EXPORT_MODULE() } else { RCTLogWarn(@"RCTSourceCode module scriptURL has not been set"); } - } else if (![sourceCodeModule.scriptURL isFileURL]) { + } else if (!(sourceCodeModule.scriptURL).fileURL) { // Live reloading is disabled when running from bundled JS file _liveReloadURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:sourceCodeModule.scriptURL]; } @@ -341,7 +341,7 @@ RCT_EXPORT_METHOD(show) } [actionSheet addButtonWithTitle:@"Cancel"]; - actionSheet.cancelButtonIndex = [actionSheet numberOfButtons] - 1; + actionSheet.cancelButtonIndex = actionSheet.numberOfButtons - 1; actionSheet.actionSheetStyle = UIBarStyleBlack; [actionSheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; diff --git a/React/Modules/RCTRedBox.m b/React/Modules/RCTRedBox.m index 2d068d75e..09c6de491 100644 --- a/React/Modules/RCTRedBox.m +++ b/React/Modules/RCTRedBox.m @@ -32,7 +32,7 @@ UITableViewCell *_cachedMessageCell; } -- (id)initWithFrame:(CGRect)frame +- (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { self.windowLevel = UIWindowLevelAlert + 1000; @@ -89,7 +89,7 @@ return self; } -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)dealloc { @@ -99,7 +99,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) - (void)openStackFrameInEditor:(NSDictionary *)stackFrame { NSData *stackFrameJSON = [RCTJSONStringify(stackFrame, nil) dataUsingEncoding:NSUTF8StringEncoding]; - NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[stackFrameJSON length]]; + NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)stackFrameJSON.length]; NSMutableURLRequest *request = [NSMutableURLRequest new]; request.URL = [RCTConvert NSURL:@"http://localhost:8081/open-stack-frame"]; request.HTTPMethod = @"POST"; @@ -135,7 +135,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) { self.hidden = YES; [self resignFirstResponder]; - [[[[UIApplication sharedApplication] delegate] window] makeKeyWindow]; + [[UIApplication sharedApplication].delegate.window makeKeyWindow]; } - (void)reload @@ -152,17 +152,17 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) - (NSInteger)tableView:(__unused UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return section == 0 ? 1 : [_lastStackTrace count]; + return section == 0 ? 1 : _lastStackTrace.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if ([indexPath section] == 0) { + if (indexPath.section == 0) { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"msg-cell"]; return [self reuseCell:cell forErrorMessage:_lastErrorMessage]; } UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; - NSUInteger index = [indexPath row]; + NSUInteger index = indexPath.row; NSDictionary *stackFrame = _lastStackTrace[index]; return [self reuseCell:cell forStackFrame:stackFrame]; } @@ -213,7 +213,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - if ([indexPath section] == 0) { + if (indexPath.section == 0) { NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; @@ -228,8 +228,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if ([indexPath section] == 1) { - NSUInteger row = [indexPath row]; + if (indexPath.section == 1) { + NSUInteger row = indexPath.row; NSDictionary *stackFrame = _lastStackTrace[row]; [self openStackFrameInEditor:stackFrame]; } diff --git a/React/Modules/RCTSourceCode.m b/React/Modules/RCTSourceCode.m index 7498728f2..08b033781 100644 --- a/React/Modules/RCTSourceCode.m +++ b/React/Modules/RCTSourceCode.m @@ -23,7 +23,7 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback failureCallback:(RCTResponseErrorBlock)failureCallback) { if (self.scriptText && self.scriptURL) { - successCallback(@[@{@"text": self.scriptText, @"url":[self.scriptURL absoluteString]}]); + successCallback(@[@{@"text": self.scriptText, @"url": self.scriptURL.absoluteString}]); } else { failureCallback(RCTErrorWithMessage(@"Source code is not available")); } @@ -31,7 +31,7 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback - (NSDictionary *)constantsToExport { - NSString *URL = [self.bridge.bundleURL absoluteString] ?: @""; + NSString *URL = self.bridge.bundleURL.absoluteString ?: @""; return @{@"scriptURL": URL}; } diff --git a/React/Modules/RCTStatusBarManager.m b/React/Modules/RCTStatusBarManager.m index 3cb4f3120..ce2364e2b 100644 --- a/React/Modules/RCTStatusBarManager.m +++ b/React/Modules/RCTStatusBarManager.m @@ -116,7 +116,7 @@ RCT_EXPORT_METHOD(setHidden:(BOOL)hidden RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible:(BOOL)visible) { - [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:visible]; + [UIApplication sharedApplication].networkActivityIndicatorVisible = visible; } @end diff --git a/React/Modules/RCTTiming.m b/React/Modules/RCTTiming.m index 09adc9560..2754925e2 100644 --- a/React/Modules/RCTTiming.m +++ b/React/Modules/RCTTiming.m @@ -145,7 +145,7 @@ RCT_EXPORT_MODULE() } // call timers that need to be called - if ([timersToCall count] > 0) { + if (timersToCall.count > 0) { [_bridge enqueueJSCall:@"JSTimersExecution.callTimers" args:@[timersToCall]]; } diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 811d661d6..7308440b1 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -731,7 +731,7 @@ RCT_EXPORT_METHOD(manageChildren:(nonnull NSNumber *)containerReactTag } } - NSArray *sortedIndices = [[destinationsToChildrenToAdd allKeys] sortedArrayUsingSelector:@selector(compare:)]; + NSArray *sortedIndices = [destinationsToChildrenToAdd.allKeys sortedArrayUsingSelector:@selector(compare:)]; for (NSNumber *reactIndex in sortedIndices) { [container insertReactSubview:destinationsToChildrenToAdd[reactIndex] atIndex:reactIndex.integerValue]; } @@ -760,7 +760,7 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ id view = [componentData createViewWithTag:reactTag]; if ([view respondsToSelector:@selector(setBackgroundColor:)]) { - [(UIView *)view setBackgroundColor:backgroundColor]; + ((UIView *)view).backgroundColor = backgroundColor; } [componentData setProps:props forView:view]; if ([view respondsToSelector:@selector(reactBridgeDidFinishTransaction)]) { @@ -810,7 +810,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po CGRect frame = [target convertRect:target.bounds toView:view]; while (target.reactTag == nil && target.superview != nil) { - target = [target superview]; + target = target.superview; } callback(@[ @@ -858,7 +858,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po } RCTProfileEndEvent(0, @"uimanager", @{ - @"view_count": @([_viewRegistry count]), + @"view_count": @(_viewRegistry.count), }); [self flushUIBlocks]; } @@ -1005,7 +1005,7 @@ RCT_EXPORT_METHOD(measureViewsInRect:(CGRect)rect return; } NSArray *childShadowViews = [shadowView reactSubviews]; - NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:[childShadowViews count]]; + NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:childShadowViews.count]; [childShadowViews enumerateObjectsUsingBlock: ^(RCTShadowView *childShadowView, NSUInteger idx, __unused BOOL *stop) { diff --git a/React/Views/RCTComponentData.m b/React/Views/RCTComponentData.m index 462513c53..8daff2a3d 100644 --- a/React/Views/RCTComponentData.m +++ b/React/Views/RCTComponentData.m @@ -60,7 +60,7 @@ typedef void (^RCTPropBlock)(id view, id json); return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (id)createViewWithTag:(NSNumber *)tag { @@ -126,7 +126,7 @@ RCT_NOT_IMPLEMENTED(-init) NSString *key = name; NSArray *parts = [keyPath componentsSeparatedByString:@"."]; if (parts) { - key = [parts lastObject]; + key = parts.lastObject; parts = [parts subarrayWithRange:(NSRange){0, parts.count - 1}]; } @@ -135,7 +135,7 @@ RCT_NOT_IMPLEMENTED(-init) // Get property setter SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set%@%@:", - [[key substringToIndex:1] uppercaseString], + [key substringToIndex:1].uppercaseString, [key substringFromIndex:1]]); // Build setter block @@ -176,8 +176,8 @@ RCT_NOT_IMPLEMENTED(-init) default: { NSInvocation *typeInvocation = [NSInvocation invocationWithMethodSignature:typeSignature]; - [typeInvocation setSelector:type]; - [typeInvocation setTarget:[RCTConvert class]]; + typeInvocation.selector = type; + typeInvocation.target = [RCTConvert class]; __block NSInvocation *sourceInvocation = nil; __block NSInvocation *targetInvocation = nil; @@ -194,7 +194,7 @@ RCT_NOT_IMPLEMENTED(-init) if (!sourceInvocation && source) { NSMethodSignature *signature = [source methodSignatureForSelector:getter]; sourceInvocation = [NSInvocation invocationWithMethodSignature:signature]; - [sourceInvocation setSelector:getter]; + sourceInvocation.selector = getter; } [sourceInvocation invokeWithTarget:source]; [sourceInvocation getReturnValue:value]; @@ -204,7 +204,7 @@ RCT_NOT_IMPLEMENTED(-init) if (!targetInvocation && target) { NSMethodSignature *signature = [target methodSignatureForSelector:setter]; targetInvocation = [NSInvocation invocationWithMethodSignature:signature]; - [targetInvocation setSelector:setter]; + targetInvocation.selector = setter; } [targetInvocation setArgument:value atIndex:2]; [targetInvocation invokeWithTarget:target]; diff --git a/React/Views/RCTDatePickerManager.m b/React/Views/RCTDatePickerManager.m index 229abb785..f2bef39e3 100644 --- a/React/Views/RCTDatePickerManager.m +++ b/React/Views/RCTDatePickerManager.m @@ -51,7 +51,7 @@ RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone) { NSDictionary *event = @{ @"target": sender.reactTag, - @"timestamp": @([sender.date timeIntervalSince1970] * 1000.0) + @"timestamp": @(sender.date.timeIntervalSince1970 * 1000.0) }; [self.bridge.eventDispatcher sendInputEventWithName:@"change" body:event]; } diff --git a/React/Views/RCTModalHostView.m b/React/Views/RCTModalHostView.m index 1650636ef..6ccbf3261 100644 --- a/React/Views/RCTModalHostView.m +++ b/React/Views/RCTModalHostView.m @@ -24,8 +24,8 @@ RCTTouchHandler *_touchHandler; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:coder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder) - (instancetype)initWithBridge:(RCTBridge *)bridge { diff --git a/React/Views/RCTNavigator.m b/React/Views/RCTNavigator.m index db9087b85..fcbc14225 100644 --- a/React/Views/RCTNavigator.m +++ b/React/Views/RCTNavigator.m @@ -293,8 +293,8 @@ NSInteger kNeverProgressed = -10000; return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)didUpdateFrame:(__unused RCTFrameUpdate *)update { @@ -501,13 +501,13 @@ BOOL jsGettingtooSlow = } if (jsGettingAhead) { if (reactPushOne) { - UIView *lastView = [_currentViews lastObject]; + UIView *lastView = _currentViews.lastObject; RCTWrapperViewController *vc = [[RCTWrapperViewController alloc] initWithNavItem:(RCTNavItem *)lastView eventDispatcher:_bridge.eventDispatcher]; vc.navigationListener = self; _numberOfViewControllerMovesToIgnore = 1; [_navigationController pushViewController:vc animated:(currentReactCount > 1)]; } else if (reactPopN) { - UIViewController *viewControllerToPopTo = [[_navigationController viewControllers] objectAtIndex:(currentReactCount - 1)]; + UIViewController *viewControllerToPopTo = _navigationController.viewControllers[(currentReactCount - 1)]; _numberOfViewControllerMovesToIgnore = viewControllerCount - currentReactCount; [_navigationController popToViewController:viewControllerToPopTo animated:YES]; } else { diff --git a/React/Views/RCTPicker.m b/React/Views/RCTPicker.m index 4134eae66..09c7247d2 100644 --- a/React/Views/RCTPicker.m +++ b/React/Views/RCTPicker.m @@ -39,8 +39,8 @@ const NSInteger UNINITIALIZED_INDEX = -1; return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)setItems:(NSArray *)items { diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index 9010bce8d..8c649da56 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -56,7 +56,7 @@ CGFloat const ZINDEX_STICKY_HEADER = 50; return self; } -RCT_NOT_IMPLEMENTED(-init) +RCT_NOT_IMPLEMENTED(- (instancetype)init) - (uint16_t)coalescingKey { @@ -266,7 +266,7 @@ RCT_NOT_IMPLEMENTED(-init) contentOffset.y = -(scrollViewSize.height - subviewSize.height) / 2.0; } } - [super setContentOffset:contentOffset]; + super.contentOffset = contentOffset; } - (void)dockClosestSectionHeader @@ -354,10 +354,6 @@ RCT_NOT_IMPLEMENTED(-init) @end -@interface RCTScrollView (Private) -- (NSArray *)calculateChildFramesData; -@end - @implementation RCTScrollView { RCTEventDispatcher *_eventDispatcher; @@ -394,8 +390,8 @@ RCT_NOT_IMPLEMENTED(-init) return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)setRemoveClippedSubviews:(__unused BOOL)removeClippedSubviews { @@ -445,8 +441,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) - (void)setClipsToBounds:(BOOL)clipsToBounds { - [super setClipsToBounds:clipsToBounds]; - [_scrollView setClipsToBounds:clipsToBounds]; + super.clipsToBounds = clipsToBounds; + _scrollView.clipsToBounds = clipsToBounds; } - (void)dealloc diff --git a/React/Views/RCTScrollViewManager.m b/React/Views/RCTScrollViewManager.m index 668ea26a3..71736a344 100644 --- a/React/Views/RCTScrollViewManager.m +++ b/React/Views/RCTScrollViewManager.m @@ -15,7 +15,9 @@ #import "RCTUIManager.h" @interface RCTScrollView (Private) + - (NSArray *)calculateChildFramesData; + @end @implementation RCTConvert (UIScrollView) diff --git a/React/Views/RCTSegmentedControl.m b/React/Views/RCTSegmentedControl.m index 28160808f..1b28bacc7 100644 --- a/React/Views/RCTSegmentedControl.m +++ b/React/Views/RCTSegmentedControl.m @@ -18,7 +18,7 @@ RCTEventDispatcher *_eventDispatcher; } -- (id)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher +- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher { if ((self = [super initWithFrame:CGRectZero])) { _eventDispatcher = eventDispatcher; diff --git a/React/Views/RCTShadowView.m b/React/Views/RCTShadowView.m index 981473020..f2870e22a 100644 --- a/React/Views/RCTShadowView.m +++ b/React/Views/RCTShadowView.m @@ -20,7 +20,7 @@ typedef void (^RCTResetActionBlock)(RCTShadowView *shadowViewSelf); const NSString *const RCTBackgroundColorProp = @"backgroundColor"; -typedef enum { +typedef NS_ENUM(unsigned int, meta_prop_t) { META_PROP_LEFT, META_PROP_TOP, META_PROP_RIGHT, @@ -29,7 +29,7 @@ typedef enum { META_PROP_VERTICAL, META_PROP_ALL, META_PROP_COUNT, -} meta_prop_t; +}; @implementation RCTShadowView { @@ -246,7 +246,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st _frame = CGRectMake(0, 0, CSS_UNDEFINED, CSS_UNDEFINED); - for (int ii = 0; ii < META_PROP_COUNT; ii++) { + for (unsigned int ii = 0; ii < META_PROP_COUNT; ii++) { _paddingMetaProps[ii] = CSS_UNDEFINED; _marginMetaProps[ii] = CSS_UNDEFINED; _borderMetaProps[ii] = CSS_UNDEFINED; @@ -326,7 +326,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st - (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex { [_reactSubviews insertObject:subview atIndex:atIndex]; - _cssNode->children_count = (int)[_reactSubviews count]; + _cssNode->children_count = (int)_reactSubviews.count; subview->_superview = self; [self dirtyText]; [self dirtyLayout]; @@ -340,7 +340,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st [subview dirtyPropagation]; subview->_superview = nil; [_reactSubviews removeObject:subview]; - _cssNode->children_count = (int)[_reactSubviews count]; + _cssNode->children_count = (int)_reactSubviews.count; } - (NSArray *)reactSubviews diff --git a/React/Views/RCTTabBar.m b/React/Views/RCTTabBar.m index 34c8a3b04..75e017a98 100644 --- a/React/Views/RCTTabBar.m +++ b/React/Views/RCTTabBar.m @@ -44,8 +44,8 @@ return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (UIViewController *)reactViewController { diff --git a/React/Views/RCTTabBarItem.m b/React/Views/RCTTabBarItem.m index 0727a846f..3695f24a7 100644 --- a/React/Views/RCTTabBarItem.m +++ b/React/Views/RCTTabBarItem.m @@ -72,7 +72,7 @@ RCTLogError(@"The tab bar icon '%@' did not match any known image or system icon", icon); return; } - _barItem = [[UITabBarItem alloc] initWithTabBarSystemItem:[systemIcon integerValue] tag:oldItem.tag]; + _barItem = [[UITabBarItem alloc] initWithTabBarSystemItem:systemIcon.integerValue tag:oldItem.tag]; } // Reapply previous properties diff --git a/React/Views/RCTTabBarItemManager.m b/React/Views/RCTTabBarItemManager.m index 9adccfdd9..f91153efd 100644 --- a/React/Views/RCTTabBarItemManager.m +++ b/React/Views/RCTTabBarItemManager.m @@ -28,7 +28,7 @@ RCT_REMAP_VIEW_PROPERTY(badge, barItem.badgeValue, NSString); RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem) { view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title; - view.barItem.imageInsets = [view.barItem.title length] ? UIEdgeInsetsZero : (UIEdgeInsets){6, 0, -6, 0}; + view.barItem.imageInsets = view.barItem.title.length ? UIEdgeInsetsZero : (UIEdgeInsets){6, 0, -6, 0}; } @end diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index af1f7842e..d242faa44 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -49,7 +49,7 @@ static UIView *RCTViewHitTest(UIView *view, CGPoint point, UIEvent *event) // we do support clipsToBounds, so if that's enabled // we'll update the clipping - if (self.clipsToBounds && [self.subviews count] > 0) { + if (self.clipsToBounds && self.subviews.count > 0) { clipRect = [clipView convertRect:clipRect toView:self]; clipRect = CGRectIntersection(clipRect, self.bounds); clipView = self; @@ -93,7 +93,7 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) { NSMutableString *str = [NSMutableString stringWithString:@""]; for (UIView *subview in view.subviews) { - NSString *label = [subview accessibilityLabel]; + NSString *label = subview.accessibilityLabel; if (label) { [str appendString:@" "]; [str appendString:label]; @@ -123,13 +123,13 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) _borderBottomLeftRadius = -1; _borderBottomRightRadius = -1; - _backgroundColor = [super backgroundColor]; + _backgroundColor = super.backgroundColor; } return self; } -RCT_NOT_IMPLEMENTED(-initWithCoder:unused) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:unused) - (NSString *)accessibilityLabel { @@ -210,8 +210,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:unused) baseInset.left += autoInset.left; baseInset.right += autoInset.right; } - [scrollView setContentInset:baseInset]; - [scrollView setScrollIndicatorInsets:baseInset]; + scrollView.contentInset = baseInset; + scrollView.scrollIndicatorInsets = baseInset; if (updateOffset) { // If we're adjusting the top inset, then let's also adjust the contentOffset so that the view @@ -333,7 +333,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:unused) return [super react_updateClippedSubviewsWithClipRect:clipRect relativeToView:clipView]; } - if ([_reactSubviews count] == 0) { + if (_reactSubviews.count == 0) { // Do nothing if we have no subviews return; } @@ -405,7 +405,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:unused) // offscreen views. If _reactSubviews is nil, we can assume // that [self reactSubviews] and [self subviews] are the same - return _reactSubviews ?: [self subviews]; + return _reactSubviews ?: self.subviews; } - (void)updateClippedSubviews diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m index bf152ea39..f6282b00b 100644 --- a/React/Views/RCTViewManager.m +++ b/React/Views/RCTViewManager.m @@ -51,7 +51,7 @@ RCT_EXPORT_MODULE() - (dispatch_queue_t)methodQueue { - return [_bridge.uiManager methodQueue]; + return _bridge.uiManager.methodQueue; } - (UIView *)view diff --git a/React/Views/RCTWebView.m b/React/Views/RCTWebView.m index 0a9e6a8d8..196284d24 100644 --- a/React/Views/RCTWebView.m +++ b/React/Views/RCTWebView.m @@ -47,8 +47,8 @@ NSString *const RCTJSNavigationScheme = @"react-js-navigation"; return self; } -RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)goForward { @@ -127,11 +127,11 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) NSString *title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"]; NSMutableDictionary *event = [[NSMutableDictionary alloc] initWithDictionary: @{ @"target": self.reactTag, - @"url": url ? [url absoluteString] : @"", + @"url": url ? url.absoluteString : @"", @"loading" : @(_webView.loading), @"title": title, - @"canGoBack": @([_webView canGoBack]), - @"canGoForward" : @([_webView canGoForward]), + @"canGoBack": @(_webView.canGoBack), + @"canGoForward" : @(_webView.canGoForward), }]; return event; @@ -148,7 +148,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) if (isTopFrame) { NSMutableDictionary *event = [self baseEvent]; [event addEntriesFromDictionary: @{ - @"url": [request.URL absoluteString], + @"url": (request.URL).absoluteString, @"navigationType": @(navigationType) }]; [_eventDispatcher sendInputEventWithName:@"loadingStart" body:event]; @@ -172,7 +172,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) [event addEntriesFromDictionary: @{ @"domain": error.domain, @"code": @(error.code), - @"description": [error localizedDescription], + @"description": error.localizedDescription, }]; [_eventDispatcher sendInputEventWithName:@"loadingError" body:event]; } diff --git a/React/Views/RCTWrapperViewController.m b/React/Views/RCTWrapperViewController.m index 169c1a7db..00af3b53d 100644 --- a/React/Views/RCTWrapperViewController.m +++ b/React/Views/RCTWrapperViewController.m @@ -52,8 +52,8 @@ return self; } -RCT_NOT_IMPLEMENTED(-initWithNibName:(NSString *)nn bundle:(NSBundle *)nb) -RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithNibName:(NSString *)nn bundle:(NSBundle *)nb) +RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) - (void)viewWillLayoutSubviews {