Ran Convert > To Modern Objective C Syntax

This commit is contained in:
Nick Lockwood 2015-08-24 09:14:33 -01:00
parent a57353b2b4
commit 88e0bbc469
80 changed files with 247 additions and 246 deletions

View File

@ -29,7 +29,7 @@
RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)"); RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
#endif #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); 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); _runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp", nil);
} }

View File

@ -50,7 +50,7 @@
// Register 20 views to use in the tests // Register 20 views to use in the tests
for (NSInteger i = 1; i <= 20; i++) { for (NSInteger i = 1; i <= 20; i++) {
UIView *registeredView = [UIView new]; UIView *registeredView = [UIView new];
[registeredView setReactTag:@(i)]; registeredView.reactTag = @(i);
_uiManager.viewRegistry[i] = registeredView; _uiManager.viewRegistry[i] = registeredView;
} }
} }
@ -92,7 +92,7 @@
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16]; NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
for (NSNumber *index in removeAtIndices) { for (NSNumber *index in removeAtIndices) {
NSNumber *reactTag = @([index integerValue] + 2); NSNumber *reactTag = @(index.integerValue + 2);
[removedViews addObject:_uiManager.viewRegistry[reactTag]]; [removedViews addObject:_uiManager.viewRegistry[reactTag]];
} }
for (NSInteger i = 2; i < 20; i++) { for (NSInteger i = 2; i < 20; i++) {

View File

@ -36,7 +36,7 @@
RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)"); RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
#endif #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); 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 = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp.ios", nil);
_runner.recordMode = NO; _runner.recordMode = NO;

View File

@ -49,7 +49,7 @@
// Register 20 views to use in the tests // Register 20 views to use in the tests
for (NSInteger i = 1; i <= 20; i++) { for (NSInteger i = 1; i <= 20; i++) {
UIView *registeredView = [UIView new]; UIView *registeredView = [UIView new];
[registeredView setReactTag:@(i)]; registeredView.reactTag = @(i);
_uiManager.viewRegistry[i] = registeredView; _uiManager.viewRegistry[i] = registeredView;
} }
} }
@ -91,7 +91,7 @@
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16]; NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
for (NSNumber *index in removeAtIndices) { for (NSNumber *index in removeAtIndices) {
NSNumber *reactTag = @([index integerValue] + 2); NSNumber *reactTag = @(index.integerValue + 2);
[removedViews addObject:_uiManager.viewRegistry[reactTag]]; [removedViews addObject:_uiManager.viewRegistry[reactTag]];
} }
for (NSInteger i = 2; i < 20; i++) { for (NSInteger i = 2; i < 20; i++) {

View File

@ -60,7 +60,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
_callbacks[RCTKeyForInstance(actionSheet)] = successCallback; _callbacks[RCTKeyForInstance(actionSheet)] = successCallback;
UIWindow *appWindow = [[[UIApplication sharedApplication] delegate] window]; UIWindow *appWindow = [UIApplication sharedApplication].delegate.window;
if (appWindow == nil) { if (appWindow == nil) {
RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options);
return; return;
@ -81,12 +81,12 @@ RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options
if (URL) { if (URL) {
[items addObject:URL]; [items addObject:URL];
} }
if ([items count] == 0) { if (items.count == 0) {
failureCallback(@[@"No `url` or `message` to share"]); failureCallback(@[@"No `url` or `message` to share"]);
return; return;
} }
UIActivityViewController *share = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; 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 #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); RCTLogWarn(@"No callback registered for action sheet: %@", actionSheet.title);
} }
[[[[UIApplication sharedApplication] delegate] window] makeKeyWindow]; [[UIApplication sharedApplication].delegate.window makeKeyWindow];
} }
#pragma mark Private #pragma mark Private

View File

@ -252,7 +252,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{ {
// Create event // Create event
CLLocation *location = [locations lastObject]; CLLocation *location = locations.lastObject;
_lastLocationEvent = @{ _lastLocationEvent = @{
@"coords": @{ @"coords": @{
@"latitude": @(location.coordinate.latitude), @"latitude": @(location.coordinate.latitude),

View File

@ -34,12 +34,12 @@ RCT_EXPORT_METHOD(saveImageWithTag:(NSString *)imageTag
errorCallback(loadError); errorCallback(loadError);
return; 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) { if (saveError) {
RCTLogWarn(@"Error saving cropped image: %@", saveError); RCTLogWarn(@"Error saving cropped image: %@", saveError);
errorCallback(saveError); errorCallback(saveError);
} else { } 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 - (void)callCallback:(RCTResponseSenderBlock)callback withAssets:(NSArray *)assets hasNextPage:(BOOL)hasNextPage
{ {
if (![assets count]) { if (!assets.count) {
callback(@[@{ callback(@[@{
@"edges": assets, @"edges": assets,
@"page_info": @{ @"page_info": @{
@ -109,14 +109,14 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stopAssets) { [group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stopAssets) {
if (result) { if (result) {
NSString *uri = [(NSURL *)[result valueForProperty:ALAssetPropertyAssetURL] absoluteString]; NSString *uri = ((NSURL *)[result valueForProperty:ALAssetPropertyAssetURL]).absoluteString;
if (afterCursor && !foundAfter) { if (afterCursor && !foundAfter) {
if ([afterCursor isEqualToString:uri]) { if ([afterCursor isEqualToString:uri]) {
foundAfter = YES; foundAfter = YES;
} }
return; // Skip until we get to the first one return; // Skip until we get to the first one
} }
if (first == [assets count]) { if (first == assets.count) {
*stopAssets = YES; *stopAssets = YES;
*stopGroups = YES; *stopGroups = YES;
hasNextPage = YES; hasNextPage = YES;
@ -138,7 +138,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
@"width": @(dimensions.width), @"width": @(dimensions.width),
@"isStored": @YES, @"isStored": @YES,
}, },
@"timestamp": @([date timeIntervalSince1970]), @"timestamp": @(date.timeIntervalSince1970),
@"location": loc ? @"location": loc ?
@{ @{
@"latitude": @(loc.coordinate.latitude), @"latitude": @(loc.coordinate.latitude),

View File

@ -85,7 +85,7 @@ CAKeyframeAnimation *RCTGIFImageWithFileURL(NSURL *URL)
return nil; return nil;
} }
if (![URL isFileURL]) { if (!URL.fileURL) {
RCTLogError(@"Loading remote image URLs synchronously is a really bad idea."); RCTLogError(@"Loading remote image URLs synchronously is a really bad idea.");
return nil; return nil;
} }

View File

@ -170,7 +170,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation,
// The 'ph://' prefix is used by FBMediaKit to differentiate between // 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 // 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. // 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]; PHFetchResult *results = [PHAsset fetchAssetsWithLocalIdentifiers:@[phAssetID] options:nil];
if (results.count == 0) { if (results.count == 0) {
NSString *errorText = [NSString stringWithFormat:@"Failed to fetch PHAsset with local identifier %@ with no error message.", phAssetID]; 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 ^{}; return ^{};
} }
PHAsset *asset = [results firstObject]; PHAsset *asset = results.firstObject;
PHImageRequestOptions *imageOptions = [PHImageRequestOptions new]; PHImageRequestOptions *imageOptions = [PHImageRequestOptions new];

View File

@ -53,7 +53,7 @@ RCT_EXPORT_METHOD(openCameraDialog:(NSDictionary *)config
successCallback:(RCTResponseSenderBlock)callback successCallback:(RCTResponseSenderBlock)callback
cancelCallback:(RCTResponseSenderBlock)cancelCallback) cancelCallback:(RCTResponseSenderBlock)cancelCallback)
{ {
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = keyWindow.rootViewController; UIViewController *rootViewController = keyWindow.rootViewController;
UIImagePickerController *imagePicker = [UIImagePickerController new]; UIImagePickerController *imagePicker = [UIImagePickerController new];
@ -75,7 +75,7 @@ RCT_EXPORT_METHOD(openSelectDialog:(NSDictionary *)config
successCallback:(RCTResponseSenderBlock)callback successCallback:(RCTResponseSenderBlock)callback
cancelCallback:(RCTResponseSenderBlock)cancelCallback) cancelCallback:(RCTResponseSenderBlock)cancelCallback)
{ {
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = keyWindow.rootViewController; UIViewController *rootViewController = keyWindow.rootViewController;
UIImagePickerController *imagePicker = [UIImagePickerController new]; UIImagePickerController *imagePicker = [UIImagePickerController new];
@ -109,7 +109,7 @@ didFinishPickingMediaWithInfo:(NSDictionary *)info
[_pickerCallbacks removeObjectAtIndex:index]; [_pickerCallbacks removeObjectAtIndex:index];
[_pickerCancelCallbacks removeObjectAtIndex:index]; [_pickerCancelCallbacks removeObjectAtIndex:index];
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = keyWindow.rootViewController; UIViewController *rootViewController = keyWindow.rootViewController;
[rootViewController dismissViewControllerAnimated:YES completion:nil]; [rootViewController dismissViewControllerAnimated:YES completion:nil];
@ -125,7 +125,7 @@ didFinishPickingMediaWithInfo:(NSDictionary *)info
[_pickerCallbacks removeObjectAtIndex:index]; [_pickerCallbacks removeObjectAtIndex:index];
[_pickerCancelCallbacks removeObjectAtIndex:index]; [_pickerCancelCallbacks removeObjectAtIndex:index];
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = keyWindow.rootViewController; UIViewController *rootViewController = keyWindow.rootViewController;
[rootViewController dismissViewControllerAnimated:YES completion:nil]; [rootViewController dismissViewControllerAnimated:YES completion:nil];

View File

@ -22,13 +22,13 @@ RCT_EXPORT_MODULE()
- (BOOL)canHandleRequest:(NSURLRequest *)request - (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 - (id)sendRequest:(NSURLRequest *)request
withDelegate:(id<RCTURLRequestDelegate>)delegate withDelegate:(id<RCTURLRequestDelegate>)delegate
{ {
NSString *URLString = [request.URL absoluteString]; NSString *URLString = request.URL.absoluteString;
__block RCTImageLoaderCancellationBlock requestToken = nil; __block RCTImageLoaderCancellationBlock requestToken = nil;
requestToken = [_bridge.imageLoader loadImageWithTag:URLString callback:^(NSError *error, UIImage *image) { requestToken = [_bridge.imageLoader loadImageWithTag:URLString callback:^(NSError *error, UIImage *image) {

View File

@ -21,7 +21,7 @@
RCT_EXPORT_MODULE() RCT_EXPORT_MODULE()
- (id)init - (instancetype)init
{ {
if ((self = [super init])) { if ((self = [super init])) {
@ -34,7 +34,7 @@ RCT_EXPORT_MODULE()
- (NSString *)storeImage:(UIImage *)image - (NSString *)storeImage:(UIImage *)image
{ {
RCTAssertMainThread(); RCTAssertMainThread();
NSString *tag = [NSString stringWithFormat:@"rct-image-store://%tu", [_store count]]; NSString *tag = [NSString stringWithFormat:@"rct-image-store://%tu", _store.count];
_store[tag] = image; _store[tag] = image;
return tag; return tag;
} }
@ -101,13 +101,13 @@ RCT_EXPORT_METHOD(addImageFromBase64:(NSString *)base64String
- (BOOL)canHandleRequest:(NSURLRequest *)request - (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 - (id)sendRequest:(NSURLRequest *)request
withDelegate:(id<RCTURLRequestDelegate>)delegate withDelegate:(id<RCTURLRequestDelegate>)delegate
{ {
NSString *imageTag = [request.URL absoluteString]; NSString *imageTag = request.URL.absoluteString;
[self getImageForTag:imageTag withBlock:^(UIImage *image) { [self getImageForTag:imageTag withBlock:^(UIImage *image) {
if (!image) { if (!image) {
NSError *error = RCTErrorWithMessage([NSString stringWithFormat:@"Invalid imageTag: %@", imageTag]); NSError *error = RCTErrorWithMessage([NSString stringWithFormat:@"Invalid imageTag: %@", imageTag]);

View File

@ -42,7 +42,7 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (void)updateImage - (void)updateImage
{ {

View File

@ -42,7 +42,7 @@ RCT_EXPORT_MODULE()
sourceApplication:(NSString *)sourceApplication sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation annotation:(id)annotation
{ {
NSDictionary *payload = @{@"url": [URL absoluteString]}; NSDictionary *payload = @{@"url": URL.absoluteString};
[[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification [[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification
object:self object:self
userInfo:payload]; userInfo:payload];
@ -52,7 +52,7 @@ RCT_EXPORT_MODULE()
- (void)handleOpenURLNotification:(NSNotification *)notification - (void)handleOpenURLNotification:(NSNotification *)notification
{ {
[_bridge.eventDispatcher sendDeviceEventWithName:@"openURL" [_bridge.eventDispatcher sendDeviceEventWithName:@"openURL"
body:[notification userInfo]]; body:notification.userInfo];
} }
RCT_EXPORT_METHOD(openURL:(NSURL *)URL) RCT_EXPORT_METHOD(openURL:(NSURL *)URL)
@ -72,7 +72,7 @@ RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL
- (NSDictionary *)constantsToExport - (NSDictionary *)constantsToExport
{ {
NSURL *initialURL = _bridge.launchOptions[UIApplicationLaunchOptionsURLKey]; NSURL *initialURL = _bridge.launchOptions[UIApplicationLaunchOptionsURLKey];
return @{@"initialURL": RCTNullIfNil([initialURL absoluteString])}; return @{@"initialURL": RCTNullIfNil(initialURL.absoluteString)};
} }
@end @end

View File

@ -51,7 +51,7 @@
_uploadProgressBlock = nil; _uploadProgressBlock = nil;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (void)cancel - (void)cancel
{ {

View File

@ -47,7 +47,7 @@ RCT_EXPORT_MODULE()
- (BOOL)canHandleRequest:(NSURLRequest *)request - (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 - (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request

View File

@ -88,7 +88,7 @@ static NSString *RCTGenerateFormBoundary()
NSMutableDictionary *headers = [parts[0][@"headers"] mutableCopy]; NSMutableDictionary *headers = [parts[0][@"headers"] mutableCopy];
NSString *partContentType = result[@"contentType"]; NSString *partContentType = result[@"contentType"];
if (partContentType != nil) { if (partContentType != nil) {
[headers setObject:partContentType forKey:@"content-type"]; headers[@"content-type"] = partContentType;
} }
[headers enumerateKeysAndObjectsUsingBlock:^(NSString *parameterKey, NSString *parameterValue, BOOL *stop) { [headers enumerateKeysAndObjectsUsingBlock:^(NSString *parameterKey, NSString *parameterValue, BOOL *stop) {
[multipartBody appendData:[[NSString stringWithFormat:@"%@: %@\r\n", parameterKey, parameterValue] [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 NSURL *URL = [RCTConvert NSURL:query[@"url"]]; // this is marked as nullable in JS, but should not be null
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; 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"]]; request.allHTTPHeaderFields = [RCTConvert NSDictionary:query[@"headers"]];
NSDictionary *data = [RCTConvert NSDictionary:RCTNilIfNull(query[@"data"])]; NSDictionary *data = [RCTConvert NSDictionary:RCTNilIfNull(query[@"data"])];
@ -161,7 +161,7 @@ RCT_EXPORT_MODULE()
// Gzip the request body // Gzip the request body
if ([request.allHTTPHeaderFields[@"Content-Encoding"] isEqualToString:@"gzip"]) { if ([request.allHTTPHeaderFields[@"Content-Encoding"] isEqualToString:@"gzip"]) {
request.HTTPBody = RCTGzipData(request.HTTPBody, -1 /* default */); 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); block(request);
@ -195,7 +195,7 @@ RCT_EXPORT_MODULE()
return NSOrderedSame; return NSOrderedSame;
} }
}]; }];
id<RCTURLRequestHandler> handler = [handlers lastObject]; id<RCTURLRequestHandler> handler = handlers.lastObject;
if (!handler) { if (!handler) {
RCTLogError(@"No suitable request handler found for %@", request.URL); RCTLogError(@"No suitable request handler found for %@", request.URL);
} }

View File

@ -108,13 +108,13 @@ RCT_EXPORT_MODULE()
- (void)handleRemoteNotificationReceived:(NSNotification *)notification - (void)handleRemoteNotificationReceived:(NSNotification *)notification
{ {
[_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationReceived" [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationReceived"
body:[notification userInfo]]; body:notification.userInfo];
} }
- (void)handleRemoteNotificationsRegistered:(NSNotification *)notification - (void)handleRemoteNotificationsRegistered:(NSNotification *)notification
{ {
[_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationsRegistered" [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationsRegistered"
body:[notification userInfo]]; body:notification.userInfo];
} }
/** /**
@ -175,7 +175,7 @@ RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)
{ {
NSUInteger types = 0; NSUInteger types = 0;
if ([UIApplication instancesRespondToSelector:@selector(currentUserNotificationSettings)]) { if ([UIApplication instancesRespondToSelector:@selector(currentUserNotificationSettings)]) {
types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types]; types = [[UIApplication sharedApplication] currentUserNotificationSettings].types;
} else { } else {
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0

View File

@ -65,7 +65,7 @@
(CGBitmapInfo)kCGImageAlphaPremultipliedLast (CGBitmapInfo)kCGImageAlphaPremultipliedLast
); );
CGFloat scaleFactor = [[UIScreen mainScreen] scale]; CGFloat scaleFactor = [UIScreen mainScreen].scale;
CGContextScaleCTM(referenceImageContext, scaleFactor, scaleFactor); CGContextScaleCTM(referenceImageContext, scaleFactor, scaleFactor);
CGContextScaleCTM(imageContext, scaleFactor, scaleFactor); CGContextScaleCTM(imageContext, scaleFactor, scaleFactor);

View File

@ -44,7 +44,7 @@ RCT_EXPORT_METHOD(verifySnapshot:(RCTResponseSenderBlock)callback)
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) { [_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
NSString *testName = NSStringFromSelector(_testSelector); NSString *testName = NSStringFromSelector(_testSelector);
_snapshotCounter[testName] = [@([_snapshotCounter[testName] integerValue] + 1) stringValue]; _snapshotCounter[testName] = (@([_snapshotCounter[testName] integerValue] + 1)).stringValue;
NSError *error = nil; NSError *error = nil;
BOOL success = [_controller compareSnapshotOfView:_view BOOL success = [_controller compareSnapshotOfView:_view

View File

@ -55,7 +55,7 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (void)setRecordMode:(BOOL)recordMode - (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 [vc.view addSubview:rootView]; // Add as subview so it doesn't get resized
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 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:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
} }

View File

@ -34,8 +34,8 @@ static css_dim_t RCTMeasure(void *context, float width)
{ {
RCTShadowText *shadowText = (__bridge RCTShadowText *)context; RCTShadowText *shadowText = (__bridge RCTShadowText *)context;
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width]; NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width];
NSLayoutManager *layoutManager = [textStorage.layoutManagers firstObject]; NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = [layoutManager.textContainers firstObject]; NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
CGSize computedSize = [layoutManager usedRectForTextContainer:textContainer].size; CGSize computedSize = [layoutManager usedRectForTextContainer:textContainer].size;
css_dim_t result; 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]]; [attributedString appendAttributedString:[shadowText _attributedStringWithFontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight fontStyle:fontStyle letterSpacing:letterSpacing useBackgroundColor:YES]];
} else if ([child isKindOfClass:[RCTShadowRawText class]]) { } else if ([child isKindOfClass:[RCTShadowRawText class]]) {
RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child; RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child;
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[shadowRawText text] ?: @""]]; [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
} else { } else {
RCTLogError(@"<Text> can't have any children except <Text> or raw strings"); RCTLogError(@"<Text> can't have any children except <Text> 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 - (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) { if (!value && attributeValue) {
[attributedString addAttribute:attribute value:attributeValue range:range]; [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) // 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) { if (value) {
NSParagraphStyle *paragraphStyle = (NSParagraphStyle *)value; NSParagraphStyle *paragraphStyle = (NSParagraphStyle *)value;
CGFloat maximumLineHeight = round([paragraphStyle maximumLineHeight] / self.fontSizeMultiplier); CGFloat maximumLineHeight = round(paragraphStyle.maximumLineHeight / self.fontSizeMultiplier);
if (maximumLineHeight > self.lineHeight) { if (maximumLineHeight > self.lineHeight) {
self.lineHeight = maximumLineHeight; self.lineHeight = maximumLineHeight;
} }
@ -305,13 +305,13 @@ static css_dim_t RCTMeasure(void *context, float width)
- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex - (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
{ {
[super insertReactSubview:subview atIndex:atIndex]; [super insertReactSubview:subview atIndex:atIndex];
[self cssNode]->children_count = 0; self.cssNode->children_count = 0;
} }
- (void)removeReactSubview:(RCTShadowView *)subview - (void)removeReactSubview:(RCTShadowView *)subview
{ {
[super removeReactSubview:subview]; [super removeReactSubview:subview];
[self cssNode]->children_count = 0; self.cssNode->children_count = 0;
} }
- (void)setBackgroundColor:(UIColor *)backgroundColor - (void)setBackgroundColor:(UIColor *)backgroundColor
@ -348,7 +348,7 @@ RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection)
_allowFontScaling = allowFontScaling; _allowFontScaling = allowFontScaling;
for (RCTShadowView *child in [self reactSubviews]) { for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) { if ([child isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)child setAllowFontScaling:allowFontScaling]; ((RCTShadowText *)child).allowFontScaling = allowFontScaling;
} }
} }
[self dirtyText]; [self dirtyText];
@ -359,7 +359,7 @@ RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection)
_fontSizeMultiplier = fontSizeMultiplier; _fontSizeMultiplier = fontSizeMultiplier;
for (RCTShadowView *child in [self reactSubviews]) { for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) { if ([child isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)child setFontSizeMultiplier:fontSizeMultiplier]; ((RCTShadowText *)child).fontSizeMultiplier = fontSizeMultiplier;
} }
} }
[self dirtyText]; [self dirtyText];

View File

@ -75,8 +75,8 @@
- (void)drawRect:(CGRect)rect - (void)drawRect:(CGRect)rect
{ {
NSLayoutManager *layoutManager = [_textStorage.layoutManagers firstObject]; NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = [layoutManager.textContainers firstObject]; NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
CGRect textFrame = UIEdgeInsetsInsetRect(self.bounds, _contentInset); CGRect textFrame = UIEdgeInsetsInsetRect(self.bounds, _contentInset);
NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer]; NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
@ -119,8 +119,8 @@
NSNumber *reactTag = self.reactTag; NSNumber *reactTag = self.reactTag;
CGFloat fraction; CGFloat fraction;
NSLayoutManager *layoutManager = [_textStorage.layoutManagers firstObject]; NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = [layoutManager.textContainers firstObject]; NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
NSUInteger characterIndex = [layoutManager characterIndexForPoint:point NSUInteger characterIndex = [layoutManager characterIndexForPoint:point
inTextContainer:textContainer inTextContainer:textContainer
fractionOfDistanceBetweenInsertionPoints:&fraction]; fractionOfDistanceBetweenInsertionPoints:&fraction];

View File

@ -36,15 +36,15 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)setText:(NSString *)text - (void)setText:(NSString *)text
{ {
NSInteger eventLag = _nativeEventCount - _mostRecentEventCount; NSInteger eventLag = _nativeEventCount - _mostRecentEventCount;
if (eventLag == 0 && ![text isEqualToString:self.text]) { if (eventLag == 0 && ![text isEqualToString:self.text]) {
UITextRange *selection = self.selectedTextRange; UITextRange *selection = self.selectedTextRange;
[super setText:text]; super.text = text;
self.selectedTextRange = selection; // maintain cursor position/selection - this is robust to out of bounds self.selectedTextRange = selection; // maintain cursor position/selection - this is robust to out of bounds
} else if (eventLag > RCTTextUpdateLagWarningThreshold) { } else if (eventLag > RCTTextUpdateLagWarningThreshold) {
RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, eventLag); RCTLogWarn(@"Native TextInput(%@) is %zd events ahead of JS - try to make your JS faster.", self.text, eventLag);

View File

@ -66,12 +66,12 @@ RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL)
} }
NSMutableArray *queue = [NSMutableArray arrayWithObject:rootView]; 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]; RCTShadowView *shadowView = queue[i];
RCTAssert([shadowView isTextDirty], @"Don't process any nodes that don't have dirty text"); RCTAssert([shadowView isTextDirty], @"Don't process any nodes that don't have dirty text");
if ([shadowView isKindOfClass:[RCTShadowText class]]) { if ([shadowView isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)shadowView setFontSizeMultiplier:self.bridge.accessibilityManager.multiplier]; ((RCTShadowText *)shadowView).fontSizeMultiplier = self.bridge.accessibilityManager.multiplier;
[(RCTShadowText *)shadowView recomputeText]; [(RCTShadowText *)shadowView recomputeText];
} else if ([shadowView isKindOfClass:[RCTShadowRawText class]]) { } else if ([shadowView isKindOfClass:[RCTShadowRawText class]]) {
RCTLogError(@"Raw text cannot be used outside of a <Text> tag. Not rendering string: '%@'", RCTLogError(@"Raw text cannot be used outside of a <Text> tag. Not rendering string: '%@'",

View File

@ -41,8 +41,8 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)updateFrames - (void)updateFrames
{ {
@ -166,7 +166,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
NSInteger eventLag = _nativeEventCount - _mostRecentEventCount; NSInteger eventLag = _nativeEventCount - _mostRecentEventCount;
if (eventLag == 0 && ![text isEqualToString:_textView.text]) { if (eventLag == 0 && ![text isEqualToString:_textView.text]) {
UITextRange *selection = _textView.selectedTextRange; UITextRange *selection = _textView.selectedTextRange;
[_textView setText:text]; _textView.text = text;
[self _setPlaceholderVisibility]; [self _setPlaceholderVisibility];
_textView.selectedTextRange = selection; // maintain cursor position/selection - this is robust to out of bounds _textView.selectedTextRange = selection; // maintain cursor position/selection - this is robust to out of bounds
} else if (eventLag > RCTTextUpdateLagWarningThreshold) { } else if (eventLag > RCTTextUpdateLagWarningThreshold) {

View File

@ -17,14 +17,14 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <Security/SecCertificate.h> #import <Security/SecCertificate.h>
typedef enum { typedef NS_ENUM(unsigned int, RCTSRReadyState) {
RCTSR_CONNECTING = 0, RCTSR_CONNECTING = 0,
RCTSR_OPEN = 1, RCTSR_OPEN = 1,
RCTSR_CLOSING = 2, RCTSR_CLOSING = 2,
RCTSR_CLOSED = 3, RCTSR_CLOSED = 3,
} RCTSRReadyState; };
typedef enum RCTSRStatusCode : NSInteger { typedef NS_ENUM(NSInteger, RCTSRStatusCode) {
RCTSRStatusCodeNormal = 1000, RCTSRStatusCodeNormal = 1000,
RCTSRStatusCodeGoingAway = 1001, RCTSRStatusCodeGoingAway = 1001,
RCTSRStatusCodeProtocolError = 1002, RCTSRStatusCodeProtocolError = 1002,
@ -35,7 +35,7 @@ typedef enum RCTSRStatusCode : NSInteger {
RCTSRStatusCodeInvalidUTF8 = 1007, RCTSRStatusCodeInvalidUTF8 = 1007,
RCTSRStatusCodePolicyViolated = 1008, RCTSRStatusCodePolicyViolated = 1008,
RCTSRStatusCodeMessageTooBig = 1009, RCTSRStatusCodeMessageTooBig = 1009,
} RCTSRStatusCode; };
@class RCTSRWebSocket; @class RCTSRWebSocket;

View File

@ -53,14 +53,14 @@ static inline void RCTSRFastLog(NSString *format, ...);
@interface NSData (RCTSRWebSocket) @interface NSData (RCTSRWebSocket)
- (NSString *)stringBySHA1ThenBase64Encoding; @property (nonatomic, readonly, copy) NSString *stringBySHA1ThenBase64Encoding;
@end @end
@interface NSString (RCTSRWebSocket) @interface NSString (RCTSRWebSocket)
- (NSString *)stringBySHA1ThenBase64Encoding; @property (nonatomic, readonly, copy) NSString *stringBySHA1ThenBase64Encoding;
@end @end
@ -69,7 +69,7 @@ static inline void RCTSRFastLog(NSString *format, ...);
// The origin isn't really applicable for a native application. // The origin isn't really applicable for a native application.
// So instead, just map ws -> http and wss -> https. // So instead, just map ws -> http and wss -> https.
- (NSString *)RCTSR_origin; @property (nonatomic, readonly, copy) NSString *RCTSR_origin;
@end @end
@ -259,7 +259,7 @@ static __strong NSData *CRLFCRLF;
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (instancetype)initWithURLRequest:(NSURLRequest *)request; - (instancetype)initWithURLRequest:(NSURLRequest *)request;
{ {
@ -511,7 +511,7 @@ RCT_NOT_IMPLEMENTED(-init)
[_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel]; [_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel];
// If we're using pinned certs, don't validate the certificate chain // 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]; [SSLOptions setValue:@NO forKey:(__bridge id)kCFStreamSSLValidatesCertificateChain];
} }
@ -998,7 +998,7 @@ static const uint8_t RCTSRPayloadLenMask = 0x7F;
- (void)_readFrameNew; - (void)_readFrameNew;
{ {
dispatch_async(_workQueue, ^{ dispatch_async(_workQueue, ^{
[_currentFrameData setLength:0]; _currentFrameData.length = 0;
_currentFrameOpcode = 0; _currentFrameOpcode = 0;
_currentFrameCount = 0; _currentFrameCount = 0;
@ -1253,7 +1253,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
[self closeWithCode:RCTSRStatusCodeMessageTooBig reason:@"Message too big"]; [self closeWithCode:RCTSRStatusCodeMessageTooBig reason:@"Message too big"];
return; return;
} }
uint8_t *frame_buffer = (uint8_t *)[frame mutableBytes]; uint8_t *frame_buffer = (uint8_t *)frame.mutableBytes;
// set fin // set fin
frame_buffer[0] = RCTSRFinMask | opcode; frame_buffer[0] = RCTSRFinMask | opcode;
@ -1318,7 +1318,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
{ {
if (_secure && !_pinnedCertFound && (eventCode == NSStreamEventHasBytesAvailable || eventCode == NSStreamEventHasSpaceAvailable)) { if (_secure && !_pinnedCertFound && (eventCode == NSStreamEventHasBytesAvailable || eventCode == NSStreamEventHasSpaceAvailable)) {
NSArray *sslCerts = [_urlRequest RCTSR_SSLPinnedCertificates]; NSArray *sslCerts = _urlRequest.RCTSR_SSLPinnedCertificates;
if (sslCerts) { if (sslCerts) {
SecTrustRef secTrust = (__bridge SecTrustRef)[aStream propertyForKey:(__bridge id)kCFStreamPropertySSLPeerTrust]; SecTrustRef secTrust = (__bridge SecTrustRef)[aStream propertyForKey:(__bridge id)kCFStreamPropertySSLPeerTrust];
if (secTrust) { if (secTrust) {
@ -1366,11 +1366,11 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
} }
case NSStreamEventErrorOccurred: { case NSStreamEventErrorOccurred: {
RCTSRFastLog(@"NSStreamEventErrorOccurred %@ %@", aStream, [[aStream streamError] copy]); RCTSRFastLog(@"NSStreamEventErrorOccurred %@ %@", aStream, [aStream.streamError copy]);
// TODO: specify error better! // TODO: specify error better!
[self _failWithError:aStream.streamError]; [self _failWithError:aStream.streamError];
_readBufferOffset = 0; _readBufferOffset = 0;
[_readBuffer setLength:0]; _readBuffer.length = 0;
break; break;
} }
@ -1475,7 +1475,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
{ {
RCTSRIOConsumer *consumer = nil; RCTSRIOConsumer *consumer = nil;
if (_bufferedConsumers.count) { if (_bufferedConsumers.count) {
consumer = [_bufferedConsumers lastObject]; consumer = _bufferedConsumers.lastObject;
[_bufferedConsumers removeLastObject]; [_bufferedConsumers removeLastObject];
} else { } else {
consumer = [RCTSRIOConsumer new]; consumer = [RCTSRIOConsumer new];
@ -1522,7 +1522,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
- (NSString *)RCTSR_origin; - (NSString *)RCTSR_origin;
{ {
NSString *scheme = [self.scheme lowercaseString]; NSString *scheme = self.scheme.lowercaseString;
if ([scheme isEqualToString:@"wss"]) { if ([scheme isEqualToString:@"wss"]) {
scheme = @"https"; scheme = @"https";

View File

@ -152,7 +152,7 @@ RCT_EXPORT_MODULE()
{ {
NSDictionary *message = @{ NSDictionary *message = @{
@"method": @"executeApplicationScript", @"method": @"executeApplicationScript",
@"url": RCTNullIfNil([URL absoluteString]), @"url": RCTNullIfNil(URL.absoluteString),
@"inject": _injectedObjects, @"inject": _injectedObjects,
}; };
[self sendMessage:message waitForReply:^(NSError *error, NSDictionary *reply) { [self sendMessage:message waitForReply:^(NSError *error, NSDictionary *reply) {

View File

@ -98,7 +98,7 @@ RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
- (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error - (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error
{ {
[_bridge.eventDispatcher sendDeviceEventWithName:@"websocketFailed" body:@{ [_bridge.eventDispatcher sendDeviceEventWithName:@"websocketFailed" body:@{
@"message":[error localizedDescription], @"message":error.localizedDescription,
@"id": webSocket.reactTag @"id": webSocket.reactTag
}]; }];
} }

View File

@ -60,7 +60,7 @@ static RCTAssertFunction RCTGetLocalAssertFunction()
{ {
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
NSArray *functionStack = threadDictionary[RCTAssertFunctionStack]; NSArray *functionStack = threadDictionary[RCTAssertFunctionStack];
RCTAssertFunction assertFunction = [functionStack lastObject]; RCTAssertFunction assertFunction = functionStack.lastObject;
if (assertFunction) { if (assertFunction) {
return assertFunction; return assertFunction;
} }
@ -83,7 +83,7 @@ void RCTPerformBlockWithAssertFunction(void (^block)(void), RCTAssertFunction as
NSString *RCTCurrentThreadName(void) NSString *RCTCurrentThreadName(void)
{ {
NSThread *thread = [NSThread currentThread]; NSThread *thread = [NSThread currentThread];
NSString *threadName = [thread isMainThread] ? @"main" : thread.name; NSString *threadName = thread.isMainThread ? @"main" : thread.name;
if (threadName.length == 0) { if (threadName.length == 0) {
const char *label = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL); const char *label = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL);
if (label && strlen(label) > 0) { if (label && strlen(label) > 0) {

View File

@ -118,7 +118,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void);
dispatch_group_t initModulesAndLoadSource = dispatch_group_create(); dispatch_group_t initModulesAndLoadSource = dispatch_group_create();
dispatch_group_enter(initModulesAndLoadSource); dispatch_group_enter(initModulesAndLoadSource);
__block NSString *sourceCode; __block NSString *sourceCode;
[self loadSource:^(NSError *error, NSString *source) { [self loadSource:^(__unused NSError *error, NSString *source) {
sourceCode = source; sourceCode = source;
dispatch_group_leave(initModulesAndLoadSource); dispatch_group_leave(initModulesAndLoadSource);
}]; }];
@ -174,7 +174,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void);
RCTPerformanceLoggerEnd(RCTPLScriptDownload); RCTPerformanceLoggerEnd(RCTPLScriptDownload);
if (error) { if (error) {
NSArray *stack = [error userInfo][@"stack"]; NSArray *stack = error.userInfo[@"stack"];
if (stack) { if (stack) {
[self.redBox showErrorMessage:error.localizedDescription [self.redBox showErrorMessage:error.localizedDescription
withStack:stack]; 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 moduleProvider:(__unused RCTBridgeModuleProviderBlock)block
launchOptions:(__unused NSDictionary *)launchOptions) launchOptions:(__unused NSDictionary *)launchOptions)
@ -634,7 +634,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
} }
for (NSUInteger fieldIndex = RCTBridgeFieldRequestModuleIDs; fieldIndex <= RCTBridgeFieldParamss; fieldIndex++) { for (NSUInteger fieldIndex = RCTBridgeFieldRequestModuleIDs; fieldIndex <= RCTBridgeFieldParamss; fieldIndex++) {
id field = [requestsArray objectAtIndex:fieldIndex]; id field = requestsArray[fieldIndex];
if (![field isKindOfClass:[NSArray class]]) { if (![field isKindOfClass:[NSArray class]]) {
RCTLogError(@"Field at index %zd in buffer must be an instance of NSArray, got %@", fieldIndex, NSStringFromClass([field class])); RCTLogError(@"Field at index %zd in buffer must be an instance of NSArray, got %@", fieldIndex, NSStringFromClass([field class]));
return; return;
@ -647,7 +647,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
NSArray *methodIDs = requestsArray[RCTBridgeFieldMethodIDs]; NSArray *methodIDs = requestsArray[RCTBridgeFieldMethodIDs];
NSArray *paramsArrays = requestsArray[RCTBridgeFieldParamss]; NSArray *paramsArrays = requestsArray[RCTBridgeFieldParamss];
NSUInteger numRequests = [moduleIDs count]; NSUInteger numRequests = moduleIDs.count;
if (RCT_DEBUG && (numRequests != methodIDs.count || numRequests != paramsArrays.count)) { if (RCT_DEBUG && (numRequests != methodIDs.count || numRequests != paramsArrays.count)) {
RCTLogError(@"Invalid data message - all must be length: %zd", numRequests); 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]; RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink];
for (RCTModuleData *moduleData in _frameUpdateObservers) { for (RCTModuleData *moduleData in _frameUpdateObservers) {
id<RCTFrameUpdateObserver> observer = (id<RCTFrameUpdateObserver>)moduleData.instance; id<RCTFrameUpdateObserver> observer = (id<RCTFrameUpdateObserver>)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];) RCT_IF_DEV(NSString *name = [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp];)
RCTProfileBeginFlowEvent(); RCTProfileBeginFlowEvent();

View File

@ -75,7 +75,7 @@ NSString *RCTBridgeModuleNameForClass(Class cls)
if ([cls respondsToSelector:NSSelectorFromString(@"moduleName")]) { if ([cls respondsToSelector:NSSelectorFromString(@"moduleName")]) {
name = [cls valueForKey:@"moduleName"]; name = [cls valueForKey:@"moduleName"];
} }
if ([name length] == 0) { if (name.length == 0) {
name = NSStringFromClass(cls); name = NSStringFromClass(cls);
} }
if ([name hasPrefix:@"RK"]) { if ([name hasPrefix:@"RK"]) {
@ -192,7 +192,7 @@ static RCTBridge *RCTCurrentBridgeInstance = nil;
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (void)dealloc - (void)dealloc
{ {

View File

@ -52,7 +52,7 @@
NSLock *_lock; NSLock *_lock;
} }
- (id)init - (instancetype)init
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
@ -103,7 +103,7 @@
- (NSUInteger)count - (NSUInteger)count
{ {
return [_cache count]; return _cache.count;
} }
- (void)cleanUp:(BOOL)keepEntries - (void)cleanUp:(BOOL)keepEntries
@ -162,7 +162,7 @@
[_lock lock]; [_lock lock];
if (_delegateRespondsToShouldEvictObject || _delegateRespondsToWillEvictObject) if (_delegateRespondsToShouldEvictObject || _delegateRespondsToWillEvictObject)
{ {
NSArray *keys = [_cache allKeys]; NSArray *keys = _cache.allKeys;
if (_delegateRespondsToShouldEvictObject) if (_delegateRespondsToShouldEvictObject)
{ {
//sort, oldest first (in case we want to use that information in our eviction test) //sort, oldest first (in case we want to use that information in our eviction test)
@ -202,7 +202,7 @@
- (void)resequence - (void)resequence
{ {
//sort, oldest first //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)); return (NSComparisonResult)MIN(1, MAX(-1, entry1.sequenceNumber - entry2.sequenceNumber));
}]; }];

View File

@ -80,10 +80,10 @@ typedef NSURL RCTFileURL;
+ (CGAffineTransform)CGAffineTransform:(id)json; + (CGAffineTransform)CGAffineTransform:(id)json;
+ (UIColor *)UIColor:(id)json; + (UIColor *)UIColor:(id)json;
+ (CGColorRef)CGColor:(id)json; + (CGColorRef)CGColor:(id)json CF_RETURNS_NOT_RETAINED;
+ (UIImage *)UIImage:(id)json; + (UIImage *)UIImage:(id)json;
+ (CGImageRef)CGImage:(id)json; + (CGImageRef)CGImage:(id)json CF_RETURNS_NOT_RETAINED;
+ (UIFont *)UIFont:(id)json; + (UIFont *)UIFont:(id)json;
+ (UIFont *)UIFont:(UIFont *)font withSize:(id)json; + (UIFont *)UIFont:(UIFont *)font withSize:(id)json;

View File

@ -95,13 +95,13 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod
} }
// Assume that it's a local path // Assume that it's a local path
path = [path stringByRemovingPercentEncoding]; path = path.stringByRemovingPercentEncoding;
if ([path hasPrefix:@"~"]) { if ([path hasPrefix:@"~"]) {
// Path is inside user directory // Path is inside user directory
path = [path stringByExpandingTildeInPath]; path = path.stringByExpandingTildeInPath;
} else if (![path isAbsolutePath]) { } else if (!path.absolutePath) {
// Assume it's a resource path // Assume it's a resource path
path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:path]; path = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:path];
} }
return [NSURL fileURLWithPath:path]; return [NSURL fileURLWithPath:path];
} }
@ -120,7 +120,7 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod
+ (RCTFileURL *)RCTFileURL:(id)json + (RCTFileURL *)RCTFileURL:(id)json
{ {
NSURL *fileURL = [self NSURL:json]; NSURL *fileURL = [self NSURL:json];
if (![fileURL isFileURL]) { if (!fileURL.fileURL) {
RCTLogError(@"URI must be a local file, '%@' isn't.", fileURL); RCTLogError(@"URI must be a local file, '%@' isn't.", fileURL);
return nil; return nil;
} }
@ -168,8 +168,8 @@ NSNumber *RCTConvertEnumValue(const char *typeName, NSDictionary *mapping, NSNum
return defaultValue; return defaultValue;
} }
if ([json isKindOfClass:[NSNumber class]]) { if ([json isKindOfClass:[NSNumber class]]) {
NSArray *allValues = [mapping allValues]; NSArray *allValues = mapping.allValues;
if ([[mapping allValues] containsObject:json] || [json isEqual:defaultValue]) { if ([mapping.allValues containsObject:json] || [json isEqual:defaultValue]) {
return json; return json;
} }
RCTLogError(@"Invalid %s '%@'. should be one of: %@", typeName, json, allValues); 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; long long result = 0;
for (id arrayElement in json) { for (id arrayElement in json) {
NSNumber *value = RCTConvertEnumValue(typeName, mapping, defaultValue, arrayElement); NSNumber *value = RCTConvertEnumValue(typeName, mapping, defaultValue, arrayElement);
result |= [value longLongValue]; result |= value.longLongValue;
} }
return @(result); return @(result);
} }
@ -582,7 +582,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[
if ([colorString hasPrefix:@"#"]) { if ([colorString hasPrefix:@"#"]) {
uint32_t redInt = 0, greenInt = 0, blueInt = 0; uint32_t redInt = 0, greenInt = 0, blueInt = 0;
if (colorString.length == 4) { // 3 digit hex 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 // expand to 6 digit hex
components.rgb.r = redInt / 15.0; components.rgb.r = redInt / 15.0;
components.rgb.g = greenInt / 15.0; components.rgb.g = greenInt / 15.0;
@ -694,10 +694,10 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[
} }
NSURL *URL = [self NSURL:path]; NSURL *URL = [self NSURL:path];
NSString *scheme = [URL.scheme lowercaseString]; NSString *scheme = URL.scheme.lowercaseString;
if (path && [scheme isEqualToString:@"file"]) { if (path && [scheme isEqualToString:@"file"]) {
if (RCT_DEBUG || [NSThread currentThread] == [NSThread mainThread]) { 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 // 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 // but to use +[UIImage imageNamed] - but this method isn't thread safe
static NSMutableDictionary *XCAssetMap = nil; static NSMutableDictionary *XCAssetMap = nil;
@ -722,7 +722,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[
if (!image) { if (!image) {
// Attempt to load from the file system // Attempt to load from the file system
if ([path pathExtension].length == 0) { if (path.pathExtension.length == 0) {
path = [path stringByAppendingPathExtension:@"png"]; path = [path stringByAppendingPathExtension:@"png"];
} }
image = [UIImage imageWithContentsOfFile:path]; image = [UIImage imageWithContentsOfFile:path];

View File

@ -29,7 +29,7 @@ NSString *RCTNormalizeInputEventName(NSString *eventName)
static NSNumber *RCTGetEventID(id<RCTEvent> event) static NSNumber *RCTGetEventID(id<RCTEvent> event)
{ {
return @( return @(
[event.viewTag intValue] | event.viewTag.intValue |
(((uint64_t)event.eventName.hash & 0xFFFF) << 32) | (((uint64_t)event.eventName.hash & 0xFFFF) << 32) |
(((uint64_t)event.coalescingKey) << 48) (((uint64_t)event.coalescingKey) << 48)
); );
@ -57,7 +57,7 @@ static NSNumber *RCTGetEventID(id<RCTEvent> event)
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (uint16_t)coalescingKey - (uint16_t)coalescingKey
{ {

View File

@ -56,8 +56,8 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)dealloc - (void)dealloc
{ {
@ -74,8 +74,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
CGFloat left = _position & RCTFPSGraphPositionLeft ? 0 : _length; CGFloat left = _position & RCTFPSGraphPositionLeft ? 0 : _length;
CAShapeLayer *graph = [CAShapeLayer new]; CAShapeLayer *graph = [CAShapeLayer new];
graph.frame = CGRectMake(left, 0, 2 * _margin + _length, self.frame.size.height); graph.frame = CGRectMake(left, 0, 2 * _margin + _length, self.frame.size.height);
graph.backgroundColor = [[color colorWithAlphaComponent:.2] CGColor]; graph.backgroundColor = [color colorWithAlphaComponent:0.2].CGColor;
graph.fillColor = [color CGColor]; graph.fillColor = color.CGColor;
return graph; return graph;
} }

View File

@ -15,7 +15,7 @@
@implementation RCTFrameUpdate @implementation RCTFrameUpdate
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (instancetype)initWithDisplayLink:(CADisplayLink *)displayLink - (instancetype)initWithDisplayLink:(CADisplayLink *)displayLink
{ {

View File

@ -16,7 +16,7 @@
@implementation RCTJavaScriptLoader @implementation RCTJavaScriptLoader
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
+ (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(RCTSourceLoadBlock)onComplete + (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(RCTSourceLoadBlock)onComplete
{ {
@ -24,7 +24,7 @@ RCT_NOT_IMPLEMENTED(-init)
scriptURL = [RCTConvert NSURL:scriptURL.absoluteString]; scriptURL = [RCTConvert NSURL:scriptURL.absoluteString];
if (!scriptURL || if (!scriptURL ||
([scriptURL isFileURL] && ![[NSFileManager defaultManager] fileExistsAtPath:scriptURL.path])) { (scriptURL.fileURL && ![[NSFileManager defaultManager] fileExistsAtPath:scriptURL.path])) {
NSError *error = [NSError errorWithDomain:@"JavaScriptLoader" code:1 userInfo:@{ NSError *error = [NSError errorWithDomain:@"JavaScriptLoader" code:1 userInfo:@{
NSLocalizedDescriptionKey: scriptURL ? [NSString stringWithFormat:@"Script at '%@' could not be found.", scriptURL] : @"No script URL provided" 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 // Handle general request errors
if (error) { if (error) {
if ([[error domain] isEqualToString:NSURLErrorDomain]) { 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]]; 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 = @{ NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: desc, NSLocalizedDescriptionKey: desc,
NSLocalizedFailureReasonErrorKey: [error localizedDescription], NSLocalizedFailureReasonErrorKey: error.localizedDescription,
NSUnderlyingErrorKey: error, NSUnderlyingErrorKey: error,
}; };
error = [NSError errorWithDomain:@"JSServer" error = [NSError errorWithDomain:@"JSServer"
@ -63,7 +63,7 @@ RCT_NOT_IMPLEMENTED(-init)
NSString *rawText = [[NSString alloc] initWithData:data encoding:encoding]; NSString *rawText = [[NSString alloc] initWithData:data encoding:encoding];
// Handle HTTP errors // Handle HTTP errors
if ([response isKindOfClass:[NSHTTPURLResponse class]] && [(NSHTTPURLResponse *)response statusCode] != 200) { if ([response isKindOfClass:[NSHTTPURLResponse class]] && ((NSHTTPURLResponse *)response).statusCode != 200) {
NSDictionary *userInfo; NSDictionary *userInfo;
NSDictionary *errorDetails = RCTJSONParse(rawText, nil); NSDictionary *errorDetails = RCTJSONParse(rawText, nil);
if ([errorDetails isKindOfClass:[NSDictionary class]] && if ([errorDetails isKindOfClass:[NSDictionary class]] &&
@ -84,7 +84,7 @@ RCT_NOT_IMPLEMENTED(-init)
userInfo = @{NSLocalizedDescriptionKey: rawText}; userInfo = @{NSLocalizedDescriptionKey: rawText};
} }
error = [NSError errorWithDomain:@"JSServer" error = [NSError errorWithDomain:@"JSServer"
code:[(NSHTTPURLResponse *)response statusCode] code:((NSHTTPURLResponse *)response).statusCode
userInfo:userInfo]; userInfo:userInfo];
onComplete(error, nil); onComplete(error, nil);

View File

@ -40,7 +40,7 @@ static BOOL RCTIsIOS8OrEarlier()
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (id)copyWithZone:(__unused NSZone *)zone - (id)copyWithZone:(__unused NSZone *)zone
{ {

View File

@ -116,7 +116,7 @@ static RCTLogFunction RCTGetLocalLogFunction()
{ {
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary; NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
NSArray *functionStack = threadDictionary[RCTLogFunctionStack]; NSArray *functionStack = threadDictionary[RCTLogFunctionStack];
RCTLogFunction logFunction = [functionStack lastObject]; RCTLogFunction logFunction = functionStack.lastObject;
if (logFunction) { if (logFunction) {
return logFunction; return logFunction;
} }
@ -171,7 +171,7 @@ NSString *RCTFormatLog(
[log appendFormat:@"[tid:%@]", RCTCurrentThreadName()]; [log appendFormat:@"[tid:%@]", RCTCurrentThreadName()];
if (fileName) { if (fileName) {
fileName = [fileName lastPathComponent]; fileName = fileName.lastPathComponent;
if (lineNumber) { if (lineNumber) {
[log appendFormat:@"[%@:%@]", fileName, lineNumber]; [log appendFormat:@"[%@:%@]", fileName, lineNumber];
} else { } else {
@ -219,7 +219,7 @@ void _RCTLogFormat(
NSRange addressRange = [frameSymbols rangeOfString:address]; NSRange addressRange = [frameSymbols rangeOfString:address];
NSString *methodName = [frameSymbols substringFromIndex:(addressRange.location + addressRange.length + 1)]; NSString *methodName = [frameSymbols substringFromIndex:(addressRange.location + addressRange.length + 1)];
if (idx == 1) { if (idx == 1) {
NSString *file = [[@(fileName) componentsSeparatedByString:@"/"] lastObject]; NSString *file = [@(fileName) componentsSeparatedByString:@"/"].lastObject;
[stack addObject:@{@"methodName": methodName, @"file": file, @"lineNumber": @(lineNumber)}]; [stack addObject:@{@"methodName": methodName, @"file": file, @"lineNumber": @(lineNumber)}];
} else { } else {
[stack addObject:@{@"methodName": methodName}]; [stack addObject:@{@"methodName": methodName}];

View File

@ -38,13 +38,12 @@
} }
// Must be done at init time due to race conditions // Must be done at init time due to race conditions
// Also, the queue setup isn't thread safe due ti static name cache (void)self.queue;
[self queue];
} }
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init); RCT_NOT_IMPLEMENTED(- (instancetype)init);
- (NSArray *)methods - (NSArray *)methods
{ {
@ -101,7 +100,7 @@ RCT_NOT_IMPLEMENTED(-init);
if (!_queue) { if (!_queue) {
BOOL implementsMethodQueue = [_instance respondsToSelector:@selector(methodQueue)]; BOOL implementsMethodQueue = [_instance respondsToSelector:@selector(methodQueue)];
if (implementsMethodQueue) { if (implementsMethodQueue) {
_queue = [_instance methodQueue]; _queue = _instance.methodQueue;
} }
if (!_queue) { if (!_queue) {

View File

@ -19,9 +19,9 @@
NSDictionary *_modulesByName; NSDictionary *_modulesByName;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
RCT_NOT_IMPLEMENTED(-initWithCoder:aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:aDecoder)
RCT_NOT_IMPLEMENTED(-initWithObjects:(const id [])objects RCT_NOT_IMPLEMENTED(- (instancetype)initWithObjects:(const id [])objects
forKeys:(const id<NSCopying> [])keys forKeys:(const id<NSCopying> [])keys
count:(NSUInteger)cnt) count:(NSUInteger)cnt)

View File

@ -60,7 +60,7 @@ static void RCTLogArgumentError(RCTModuleMethod *method, NSUInteger index,
method->_JSMethodName, issue); method->_JSMethodName, issue);
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
void RCTParseObjCMethodName(NSString **, NSArray **); void RCTParseObjCMethodName(NSString **, NSArray **);
void RCTParseObjCMethodName(NSString **objCMethodName, NSArray **arguments) void RCTParseObjCMethodName(NSString **objCMethodName, NSArray **arguments)
@ -154,7 +154,7 @@ void RCTParseObjCMethodName(NSString **objCMethodName, NSArray **arguments)
NSMethodSignature *methodSignature = [_moduleClass instanceMethodSignatureForSelector:_selector]; NSMethodSignature *methodSignature = [_moduleClass instanceMethodSignatureForSelector:_selector];
RCTAssert(methodSignature, @"%@ is not a recognized Objective-C method.", objCMethodName); RCTAssert(methodSignature, @"%@ is not a recognized Objective-C method.", objCMethodName);
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature];
[invocation setSelector:_selector]; invocation.selector = _selector;
[invocation retainArguments]; [invocation retainArguments];
_invocation = invocation; _invocation = invocation;
@ -234,8 +234,8 @@ void RCTParseObjCMethodName(NSString **objCMethodName, NSArray **arguments)
NSMethodSignature *typeSignature = [RCTConvert methodSignatureForSelector:selector]; NSMethodSignature *typeSignature = [RCTConvert methodSignatureForSelector:selector];
NSInvocation *typeInvocation = [NSInvocation invocationWithMethodSignature:typeSignature]; NSInvocation *typeInvocation = [NSInvocation invocationWithMethodSignature:typeSignature];
[typeInvocation setSelector:selector]; typeInvocation.selector = selector;
[typeInvocation setTarget:[RCTConvert class]]; typeInvocation.target = [RCTConvert class];
[argumentBlocks addObject:^(__unused RCTBridge *bridge, NSUInteger index, id json) { [argumentBlocks addObject:^(__unused RCTBridge *bridge, NSUInteger index, id json) {
void *returnValue = malloc(typeSignature.methodReturnLength); void *returnValue = malloc(typeSignature.methodReturnLength);

View File

@ -66,7 +66,7 @@ RCT_EXPORT_MODULE()
- (void)show - (void)show
{ {
UIView *targetView = [[[[[UIApplication sharedApplication] delegate] window] rootViewController] view]; UIView *targetView = [UIApplication sharedApplication].delegate.window.rootViewController.view;
targetView.frame = (CGRect){ targetView.frame = (CGRect){
targetView.frame.origin, targetView.frame.origin,

View File

@ -289,7 +289,7 @@ void RCTProfileEndEvent(
CHECK(); CHECK();
NSMutableArray *events = RCTProfileGetThreadEvents(); NSMutableArray *events = RCTProfileGetThreadEvents();
NSArray *event = [events lastObject]; NSArray *event = events.lastObject;
[events removeLastObject]; [events removeLastObject];
if (!event) { if (!event) {

View File

@ -44,7 +44,7 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
@property (nonatomic, readonly) BOOL contentHasAppeared; @property (nonatomic, readonly) BOOL contentHasAppeared;
- (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge; - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
@end @end
@ -104,8 +104,8 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat
return [self initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; return [self initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)setBackgroundColor:(UIColor *)backgroundColor - (void)setBackgroundColor:(UIColor *)backgroundColor
{ {
@ -237,7 +237,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
bridge:(RCTBridge *)bridge bridge:(RCTBridge *)bridge
{ {
if ((self = [super init])) { if ((self = [super initWithFrame:frame])) {
_bridge = bridge; _bridge = bridge;
[self setUp]; [self setUp];
self.frame = frame; self.frame = frame;
@ -246,6 +246,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder:(nonnull NSCoder *)aDecoder)
- (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex - (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex
{ {
[super insertReactSubview:subview atIndex:atIndex]; [super insertReactSubview:subview atIndex:atIndex];

View File

@ -117,7 +117,7 @@
- (NSString *)description - (NSString *)description
{ {
return [[super description] stringByAppendingString:[_storage description]]; return [super.description stringByAppendingString:_storage.description];
} }
@end @end

View File

@ -60,7 +60,7 @@
return self; 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) { typedef NS_ENUM(NSInteger, RCTTouchEventType) {
RCTTouchEventTypeStart, 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 gesture just recognized, send all touches to JS as if they just began.
if (self.state == UIGestureRecognizerStateBegan) { 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 // We store this flag separately from `state` because after a gesture is
// recognized, its `state` changes immediately but its action (this // recognized, its `state` changes immediately but its action (this

View File

@ -171,7 +171,7 @@ id RCTJSONClean(id object)
NSString *RCTMD5Hash(NSString *string) NSString *RCTMD5Hash(NSString *string)
{ {
const char *str = [string UTF8String]; const char *str = string.UTF8String;
unsigned char result[CC_MD5_DIGEST_LENGTH]; unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5(str, (CC_LONG)strlen(str), result); CC_MD5(str, (CC_LONG)strlen(str), result);

View File

@ -41,7 +41,7 @@
@property (nonatomic, assign, readonly) JSGlobalContextRef ctx; @property (nonatomic, assign, readonly) JSGlobalContextRef ctx;
- (instancetype)initWithJSContext:(JSGlobalContextRef)context; - (instancetype)initWithJSContext:(JSGlobalContextRef)context NS_DESIGNATED_INITIALIZER;
@end @end
@ -59,6 +59,8 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-(instancetype)init)
- (BOOL)isValid - (BOOL)isValid
{ {
return _ctx != NULL; return _ctx != NULL;
@ -195,7 +197,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
{ {
@autoreleasepool { @autoreleasepool {
// copy thread name to pthread name // 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 // Set up a dummy runloop source to avoid spinning
CFRunLoopSourceContext noSpinCtx = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; 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); CFRelease(noSpinSource);
// run the run loop // 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. 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] NSThread *javaScriptThread = [[NSThread alloc] initWithTarget:[self class]
selector:@selector(runRunLoopThread) selector:@selector(runRunLoopThread)
object:nil]; object:nil];
[javaScriptThread setName:@"com.facebook.React.JavaScript"]; javaScriptThread.name = @"com.facebook.React.JavaScript";
[javaScriptThread setThreadPriority:[[NSThread mainThread] threadPriority]]; javaScriptThread.threadPriority = [NSThread mainThread].threadPriority;
[javaScriptThread start]; [javaScriptThread start];
return [self initWithJavaScriptThread:javaScriptThread globalContextRef:NULL]; return [self initWithJavaScriptThread:javaScriptThread globalContextRef:NULL];

View File

@ -58,7 +58,7 @@ RCT_EXPORT_MODULE()
return self; return self;
} }
- (id)init - (instancetype)init
{ {
return [self initWithWebView:nil]; return [self initWithWebView:nil];
} }

View File

@ -61,7 +61,7 @@ RCT_EXPORT_MODULE()
selector:@selector(didReceiveNewContentSizeCategory:) selector:@selector(didReceiveNewContentSizeCategory:)
name:UIContentSizeCategoryDidChangeNotification name:UIContentSizeCategoryDidChangeNotification
object:[UIApplication sharedApplication]]; object:[UIApplication sharedApplication]];
self.contentSizeCategory = [[UIApplication sharedApplication] preferredContentSizeCategory]; self.contentSizeCategory = [UIApplication sharedApplication].preferredContentSizeCategory;
} }
return self; return self;
} }

View File

@ -90,7 +90,7 @@ RCT_EXPORT_METHOD(alertWithArgs:(NSDictionary *)args
if (button.count != 1) { if (button.count != 1) {
RCTLogError(@"Button definitions should have exactly one key."); RCTLogError(@"Button definitions should have exactly one key.");
} }
NSString *buttonKey = [button.allKeys firstObject]; NSString *buttonKey = button.allKeys.firstObject;
NSString *buttonTitle = [button[buttonKey] description]; NSString *buttonTitle = [button[buttonKey] description];
[alertView addButtonWithTitle:buttonTitle]; [alertView addButtonWithTitle:buttonTitle];
if ([buttonKey isEqualToString: @"cancel"]) { if ([buttonKey isEqualToString: @"cancel"]) {

View File

@ -25,7 +25,7 @@ static NSString *RCTCurrentAppBackgroundState()
}; };
}); });
return states[@([[UIApplication sharedApplication] applicationState])] ?: @"unknown"; return states[@([UIApplication sharedApplication].applicationState)] ?: @"unknown";
} }
@implementation RCTAppState @implementation RCTAppState

View File

@ -66,7 +66,7 @@ static NSString *RCTGetStorageDirectory()
static NSString *storageDirectory = nil; static NSString *storageDirectory = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
storageDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; storageDirectory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
storageDirectory = [storageDirectory stringByAppendingPathComponent:RCTStorageDirectory]; storageDirectory = [storageDirectory stringByAppendingPathComponent:RCTStorageDirectory];
}); });
return storageDirectory; return storageDirectory;
@ -390,7 +390,7 @@ RCT_EXPORT_METHOD(getAllKeys:(RCTResponseSenderBlock)callback)
if (errorOut) { if (errorOut) {
callback(@[errorOut, (id)kCFNull]); callback(@[errorOut, (id)kCFNull]);
} else { } else {
callback(@[(id)kCFNull, [_manifest allKeys]]); callback(@[(id)kCFNull, _manifest.allKeys]);
} }
} }

View File

@ -61,7 +61,7 @@ RCT_EXPORT_MODULE()
_showDate = [NSDate date]; _showDate = [NSDate date];
if (!_window && !RCTRunningInTestEnvironment()) { 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 = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 22)];
_window.backgroundColor = [UIColor blackColor]; _window.backgroundColor = [UIColor blackColor];
_window.windowLevel = UIWindowLevelStatusBar + 1; _window.windowLevel = UIWindowLevelStatusBar + 1;
@ -76,10 +76,10 @@ RCT_EXPORT_MODULE()
} }
NSString *source; NSString *source;
if ([URL isFileURL]) { if (URL.fileURL) {
source = @"pre-bundled file"; source = @"pre-bundled file";
} else { } else {
source = [NSString stringWithFormat:@"%@:%@", [URL host], [URL port]]; source = [NSString stringWithFormat:@"%@:%@", URL.host, URL.port];
} }
_label.text = [NSString stringWithFormat:@"Loading from %@...", source]; _label.text = [NSString stringWithFormat:@"Loading from %@...", source];

View File

@ -64,7 +64,7 @@ static NSString *const RCTDevMenuSettingsKey = @"RCTDevMenu";
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
@end @end
@ -210,7 +210,7 @@ RCT_EXPORT_MODULE()
} else { } else {
RCTLogWarn(@"RCTSourceCode module scriptURL has not been set"); 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 // Live reloading is disabled when running from bundled JS file
_liveReloadURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:sourceCodeModule.scriptURL]; _liveReloadURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:sourceCodeModule.scriptURL];
} }
@ -341,7 +341,7 @@ RCT_EXPORT_METHOD(show)
} }
[actionSheet addButtonWithTitle:@"Cancel"]; [actionSheet addButtonWithTitle:@"Cancel"];
actionSheet.cancelButtonIndex = [actionSheet numberOfButtons] - 1; actionSheet.cancelButtonIndex = actionSheet.numberOfButtons - 1;
actionSheet.actionSheetStyle = UIBarStyleBlack; actionSheet.actionSheetStyle = UIBarStyleBlack;
[actionSheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; [actionSheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view];

View File

@ -32,7 +32,7 @@
UITableViewCell *_cachedMessageCell; UITableViewCell *_cachedMessageCell;
} }
- (id)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
if ((self = [super initWithFrame:frame])) { if ((self = [super initWithFrame:frame])) {
self.windowLevel = UIWindowLevelAlert + 1000; self.windowLevel = UIWindowLevelAlert + 1000;
@ -89,7 +89,7 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)dealloc - (void)dealloc
{ {
@ -99,7 +99,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
- (void)openStackFrameInEditor:(NSDictionary *)stackFrame - (void)openStackFrameInEditor:(NSDictionary *)stackFrame
{ {
NSData *stackFrameJSON = [RCTJSONStringify(stackFrame, nil) dataUsingEncoding:NSUTF8StringEncoding]; 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]; NSMutableURLRequest *request = [NSMutableURLRequest new];
request.URL = [RCTConvert NSURL:@"http://localhost:8081/open-stack-frame"]; request.URL = [RCTConvert NSURL:@"http://localhost:8081/open-stack-frame"];
request.HTTPMethod = @"POST"; request.HTTPMethod = @"POST";
@ -135,7 +135,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
{ {
self.hidden = YES; self.hidden = YES;
[self resignFirstResponder]; [self resignFirstResponder];
[[[[UIApplication sharedApplication] delegate] window] makeKeyWindow]; [[UIApplication sharedApplication].delegate.window makeKeyWindow];
} }
- (void)reload - (void)reload
@ -152,17 +152,17 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
- (NSInteger)tableView:(__unused UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (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 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if ([indexPath section] == 0) { if (indexPath.section == 0) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"msg-cell"]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"msg-cell"];
return [self reuseCell:cell forErrorMessage:_lastErrorMessage]; return [self reuseCell:cell forErrorMessage:_lastErrorMessage];
} }
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
NSUInteger index = [indexPath row]; NSUInteger index = indexPath.row;
NSDictionary *stackFrame = _lastStackTrace[index]; NSDictionary *stackFrame = _lastStackTrace[index];
return [self reuseCell:cell forStackFrame:stackFrame]; return [self reuseCell:cell forStackFrame:stackFrame];
} }
@ -213,7 +213,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if ([indexPath section] == 0) { if (indexPath.section == 0) {
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
@ -228,8 +228,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if ([indexPath section] == 1) { if (indexPath.section == 1) {
NSUInteger row = [indexPath row]; NSUInteger row = indexPath.row;
NSDictionary *stackFrame = _lastStackTrace[row]; NSDictionary *stackFrame = _lastStackTrace[row];
[self openStackFrameInEditor:stackFrame]; [self openStackFrameInEditor:stackFrame];
} }

View File

@ -23,7 +23,7 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
failureCallback:(RCTResponseErrorBlock)failureCallback) failureCallback:(RCTResponseErrorBlock)failureCallback)
{ {
if (self.scriptText && self.scriptURL) { if (self.scriptText && self.scriptURL) {
successCallback(@[@{@"text": self.scriptText, @"url":[self.scriptURL absoluteString]}]); successCallback(@[@{@"text": self.scriptText, @"url": self.scriptURL.absoluteString}]);
} else { } else {
failureCallback(RCTErrorWithMessage(@"Source code is not available")); failureCallback(RCTErrorWithMessage(@"Source code is not available"));
} }
@ -31,7 +31,7 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
- (NSDictionary *)constantsToExport - (NSDictionary *)constantsToExport
{ {
NSString *URL = [self.bridge.bundleURL absoluteString] ?: @""; NSString *URL = self.bridge.bundleURL.absoluteString ?: @"";
return @{@"scriptURL": URL}; return @{@"scriptURL": URL};
} }

View File

@ -116,7 +116,7 @@ RCT_EXPORT_METHOD(setHidden:(BOOL)hidden
RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible:(BOOL)visible) RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible:(BOOL)visible)
{ {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:visible]; [UIApplication sharedApplication].networkActivityIndicatorVisible = visible;
} }
@end @end

View File

@ -145,7 +145,7 @@ RCT_EXPORT_MODULE()
} }
// call timers that need to be called // call timers that need to be called
if ([timersToCall count] > 0) { if (timersToCall.count > 0) {
[_bridge enqueueJSCall:@"JSTimersExecution.callTimers" args:@[timersToCall]]; [_bridge enqueueJSCall:@"JSTimersExecution.callTimers" args:@[timersToCall]];
} }

View File

@ -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) { for (NSNumber *reactIndex in sortedIndices) {
[container insertReactSubview:destinationsToChildrenToAdd[reactIndex] atIndex:reactIndex.integerValue]; [container insertReactSubview:destinationsToChildrenToAdd[reactIndex] atIndex:reactIndex.integerValue];
} }
@ -760,7 +760,7 @@ RCT_EXPORT_METHOD(createView:(nonnull NSNumber *)reactTag
[self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){ [self addUIBlock:^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry){
id<RCTComponent> view = [componentData createViewWithTag:reactTag]; id<RCTComponent> view = [componentData createViewWithTag:reactTag];
if ([view respondsToSelector:@selector(setBackgroundColor:)]) { if ([view respondsToSelector:@selector(setBackgroundColor:)]) {
[(UIView *)view setBackgroundColor:backgroundColor]; ((UIView *)view).backgroundColor = backgroundColor;
} }
[componentData setProps:props forView:view]; [componentData setProps:props forView:view];
if ([view respondsToSelector:@selector(reactBridgeDidFinishTransaction)]) { 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]; CGRect frame = [target convertRect:target.bounds toView:view];
while (target.reactTag == nil && target.superview != nil) { while (target.reactTag == nil && target.superview != nil) {
target = [target superview]; target = target.superview;
} }
callback(@[ callback(@[
@ -858,7 +858,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
} }
RCTProfileEndEvent(0, @"uimanager", @{ RCTProfileEndEvent(0, @"uimanager", @{
@"view_count": @([_viewRegistry count]), @"view_count": @(_viewRegistry.count),
}); });
[self flushUIBlocks]; [self flushUIBlocks];
} }
@ -1005,7 +1005,7 @@ RCT_EXPORT_METHOD(measureViewsInRect:(CGRect)rect
return; return;
} }
NSArray *childShadowViews = [shadowView reactSubviews]; NSArray *childShadowViews = [shadowView reactSubviews];
NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:[childShadowViews count]]; NSMutableArray *results = [[NSMutableArray alloc] initWithCapacity:childShadowViews.count];
[childShadowViews enumerateObjectsUsingBlock: [childShadowViews enumerateObjectsUsingBlock:
^(RCTShadowView *childShadowView, NSUInteger idx, __unused BOOL *stop) { ^(RCTShadowView *childShadowView, NSUInteger idx, __unused BOOL *stop) {

View File

@ -60,7 +60,7 @@ typedef void (^RCTPropBlock)(id<RCTComponent> view, id json);
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (id<RCTComponent>)createViewWithTag:(NSNumber *)tag - (id<RCTComponent>)createViewWithTag:(NSNumber *)tag
{ {
@ -126,7 +126,7 @@ RCT_NOT_IMPLEMENTED(-init)
NSString *key = name; NSString *key = name;
NSArray *parts = [keyPath componentsSeparatedByString:@"."]; NSArray *parts = [keyPath componentsSeparatedByString:@"."];
if (parts) { if (parts) {
key = [parts lastObject]; key = parts.lastObject;
parts = [parts subarrayWithRange:(NSRange){0, parts.count - 1}]; parts = [parts subarrayWithRange:(NSRange){0, parts.count - 1}];
} }
@ -135,7 +135,7 @@ RCT_NOT_IMPLEMENTED(-init)
// Get property setter // Get property setter
SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set%@%@:", SEL setter = NSSelectorFromString([NSString stringWithFormat:@"set%@%@:",
[[key substringToIndex:1] uppercaseString], [key substringToIndex:1].uppercaseString,
[key substringFromIndex:1]]); [key substringFromIndex:1]]);
// Build setter block // Build setter block
@ -176,8 +176,8 @@ RCT_NOT_IMPLEMENTED(-init)
default: { default: {
NSInvocation *typeInvocation = [NSInvocation invocationWithMethodSignature:typeSignature]; NSInvocation *typeInvocation = [NSInvocation invocationWithMethodSignature:typeSignature];
[typeInvocation setSelector:type]; typeInvocation.selector = type;
[typeInvocation setTarget:[RCTConvert class]]; typeInvocation.target = [RCTConvert class];
__block NSInvocation *sourceInvocation = nil; __block NSInvocation *sourceInvocation = nil;
__block NSInvocation *targetInvocation = nil; __block NSInvocation *targetInvocation = nil;
@ -194,7 +194,7 @@ RCT_NOT_IMPLEMENTED(-init)
if (!sourceInvocation && source) { if (!sourceInvocation && source) {
NSMethodSignature *signature = [source methodSignatureForSelector:getter]; NSMethodSignature *signature = [source methodSignatureForSelector:getter];
sourceInvocation = [NSInvocation invocationWithMethodSignature:signature]; sourceInvocation = [NSInvocation invocationWithMethodSignature:signature];
[sourceInvocation setSelector:getter]; sourceInvocation.selector = getter;
} }
[sourceInvocation invokeWithTarget:source]; [sourceInvocation invokeWithTarget:source];
[sourceInvocation getReturnValue:value]; [sourceInvocation getReturnValue:value];
@ -204,7 +204,7 @@ RCT_NOT_IMPLEMENTED(-init)
if (!targetInvocation && target) { if (!targetInvocation && target) {
NSMethodSignature *signature = [target methodSignatureForSelector:setter]; NSMethodSignature *signature = [target methodSignatureForSelector:setter];
targetInvocation = [NSInvocation invocationWithMethodSignature:signature]; targetInvocation = [NSInvocation invocationWithMethodSignature:signature];
[targetInvocation setSelector:setter]; targetInvocation.selector = setter;
} }
[targetInvocation setArgument:value atIndex:2]; [targetInvocation setArgument:value atIndex:2];
[targetInvocation invokeWithTarget:target]; [targetInvocation invokeWithTarget:target];

View File

@ -51,7 +51,7 @@ RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone)
{ {
NSDictionary *event = @{ NSDictionary *event = @{
@"target": sender.reactTag, @"target": sender.reactTag,
@"timestamp": @([sender.date timeIntervalSince1970] * 1000.0) @"timestamp": @(sender.date.timeIntervalSince1970 * 1000.0)
}; };
[self.bridge.eventDispatcher sendInputEventWithName:@"change" body:event]; [self.bridge.eventDispatcher sendInputEventWithName:@"change" body:event];
} }

View File

@ -24,8 +24,8 @@
RCTTouchHandler *_touchHandler; RCTTouchHandler *_touchHandler;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:coder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
- (instancetype)initWithBridge:(RCTBridge *)bridge - (instancetype)initWithBridge:(RCTBridge *)bridge
{ {

View File

@ -293,8 +293,8 @@ NSInteger kNeverProgressed = -10000;
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)didUpdateFrame:(__unused RCTFrameUpdate *)update - (void)didUpdateFrame:(__unused RCTFrameUpdate *)update
{ {
@ -501,13 +501,13 @@ BOOL jsGettingtooSlow =
} }
if (jsGettingAhead) { if (jsGettingAhead) {
if (reactPushOne) { if (reactPushOne) {
UIView *lastView = [_currentViews lastObject]; UIView *lastView = _currentViews.lastObject;
RCTWrapperViewController *vc = [[RCTWrapperViewController alloc] initWithNavItem:(RCTNavItem *)lastView eventDispatcher:_bridge.eventDispatcher]; RCTWrapperViewController *vc = [[RCTWrapperViewController alloc] initWithNavItem:(RCTNavItem *)lastView eventDispatcher:_bridge.eventDispatcher];
vc.navigationListener = self; vc.navigationListener = self;
_numberOfViewControllerMovesToIgnore = 1; _numberOfViewControllerMovesToIgnore = 1;
[_navigationController pushViewController:vc animated:(currentReactCount > 1)]; [_navigationController pushViewController:vc animated:(currentReactCount > 1)];
} else if (reactPopN) { } else if (reactPopN) {
UIViewController *viewControllerToPopTo = [[_navigationController viewControllers] objectAtIndex:(currentReactCount - 1)]; UIViewController *viewControllerToPopTo = _navigationController.viewControllers[(currentReactCount - 1)];
_numberOfViewControllerMovesToIgnore = viewControllerCount - currentReactCount; _numberOfViewControllerMovesToIgnore = viewControllerCount - currentReactCount;
[_navigationController popToViewController:viewControllerToPopTo animated:YES]; [_navigationController popToViewController:viewControllerToPopTo animated:YES];
} else { } else {

View File

@ -39,8 +39,8 @@ const NSInteger UNINITIALIZED_INDEX = -1;
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)setItems:(NSArray *)items - (void)setItems:(NSArray *)items
{ {

View File

@ -56,7 +56,7 @@ CGFloat const ZINDEX_STICKY_HEADER = 50;
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-init) RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (uint16_t)coalescingKey - (uint16_t)coalescingKey
{ {
@ -266,7 +266,7 @@ RCT_NOT_IMPLEMENTED(-init)
contentOffset.y = -(scrollViewSize.height - subviewSize.height) / 2.0; contentOffset.y = -(scrollViewSize.height - subviewSize.height) / 2.0;
} }
} }
[super setContentOffset:contentOffset]; super.contentOffset = contentOffset;
} }
- (void)dockClosestSectionHeader - (void)dockClosestSectionHeader
@ -354,10 +354,6 @@ RCT_NOT_IMPLEMENTED(-init)
@end @end
@interface RCTScrollView (Private)
- (NSArray *)calculateChildFramesData;
@end
@implementation RCTScrollView @implementation RCTScrollView
{ {
RCTEventDispatcher *_eventDispatcher; RCTEventDispatcher *_eventDispatcher;
@ -394,8 +390,8 @@ RCT_NOT_IMPLEMENTED(-init)
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)setRemoveClippedSubviews:(__unused BOOL)removeClippedSubviews - (void)setRemoveClippedSubviews:(__unused BOOL)removeClippedSubviews
{ {
@ -445,8 +441,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
- (void)setClipsToBounds:(BOOL)clipsToBounds - (void)setClipsToBounds:(BOOL)clipsToBounds
{ {
[super setClipsToBounds:clipsToBounds]; super.clipsToBounds = clipsToBounds;
[_scrollView setClipsToBounds:clipsToBounds]; _scrollView.clipsToBounds = clipsToBounds;
} }
- (void)dealloc - (void)dealloc

View File

@ -15,7 +15,9 @@
#import "RCTUIManager.h" #import "RCTUIManager.h"
@interface RCTScrollView (Private) @interface RCTScrollView (Private)
- (NSArray *)calculateChildFramesData; - (NSArray *)calculateChildFramesData;
@end @end
@implementation RCTConvert (UIScrollView) @implementation RCTConvert (UIScrollView)

View File

@ -18,7 +18,7 @@
RCTEventDispatcher *_eventDispatcher; RCTEventDispatcher *_eventDispatcher;
} }
- (id)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{ {
if ((self = [super initWithFrame:CGRectZero])) { if ((self = [super initWithFrame:CGRectZero])) {
_eventDispatcher = eventDispatcher; _eventDispatcher = eventDispatcher;

View File

@ -20,7 +20,7 @@ typedef void (^RCTResetActionBlock)(RCTShadowView *shadowViewSelf);
const NSString *const RCTBackgroundColorProp = @"backgroundColor"; const NSString *const RCTBackgroundColorProp = @"backgroundColor";
typedef enum { typedef NS_ENUM(unsigned int, meta_prop_t) {
META_PROP_LEFT, META_PROP_LEFT,
META_PROP_TOP, META_PROP_TOP,
META_PROP_RIGHT, META_PROP_RIGHT,
@ -29,7 +29,7 @@ typedef enum {
META_PROP_VERTICAL, META_PROP_VERTICAL,
META_PROP_ALL, META_PROP_ALL,
META_PROP_COUNT, META_PROP_COUNT,
} meta_prop_t; };
@implementation RCTShadowView @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); _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; _paddingMetaProps[ii] = CSS_UNDEFINED;
_marginMetaProps[ii] = CSS_UNDEFINED; _marginMetaProps[ii] = CSS_UNDEFINED;
_borderMetaProps[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 - (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
{ {
[_reactSubviews insertObject:subview atIndex:atIndex]; [_reactSubviews insertObject:subview atIndex:atIndex];
_cssNode->children_count = (int)[_reactSubviews count]; _cssNode->children_count = (int)_reactSubviews.count;
subview->_superview = self; subview->_superview = self;
[self dirtyText]; [self dirtyText];
[self dirtyLayout]; [self dirtyLayout];
@ -340,7 +340,7 @@ static void RCTProcessMetaProps(const float metaProps[META_PROP_COUNT], float st
[subview dirtyPropagation]; [subview dirtyPropagation];
subview->_superview = nil; subview->_superview = nil;
[_reactSubviews removeObject:subview]; [_reactSubviews removeObject:subview];
_cssNode->children_count = (int)[_reactSubviews count]; _cssNode->children_count = (int)_reactSubviews.count;
} }
- (NSArray *)reactSubviews - (NSArray *)reactSubviews

View File

@ -44,8 +44,8 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (UIViewController *)reactViewController - (UIViewController *)reactViewController
{ {

View File

@ -72,7 +72,7 @@
RCTLogError(@"The tab bar icon '%@' did not match any known image or system icon", icon); RCTLogError(@"The tab bar icon '%@' did not match any known image or system icon", icon);
return; return;
} }
_barItem = [[UITabBarItem alloc] initWithTabBarSystemItem:[systemIcon integerValue] tag:oldItem.tag]; _barItem = [[UITabBarItem alloc] initWithTabBarSystemItem:systemIcon.integerValue tag:oldItem.tag];
} }
// Reapply previous properties // Reapply previous properties

View File

@ -28,7 +28,7 @@ RCT_REMAP_VIEW_PROPERTY(badge, barItem.badgeValue, NSString);
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem) RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
{ {
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title; 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 @end

View File

@ -49,7 +49,7 @@ static UIView *RCTViewHitTest(UIView *view, CGPoint point, UIEvent *event)
// we do support clipsToBounds, so if that's enabled // we do support clipsToBounds, so if that's enabled
// we'll update the clipping // 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 = [clipView convertRect:clipRect toView:self];
clipRect = CGRectIntersection(clipRect, self.bounds); clipRect = CGRectIntersection(clipRect, self.bounds);
clipView = self; clipView = self;
@ -93,7 +93,7 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view)
{ {
NSMutableString *str = [NSMutableString stringWithString:@""]; NSMutableString *str = [NSMutableString stringWithString:@""];
for (UIView *subview in view.subviews) { for (UIView *subview in view.subviews) {
NSString *label = [subview accessibilityLabel]; NSString *label = subview.accessibilityLabel;
if (label) { if (label) {
[str appendString:@" "]; [str appendString:@" "];
[str appendString:label]; [str appendString:label];
@ -123,13 +123,13 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view)
_borderBottomLeftRadius = -1; _borderBottomLeftRadius = -1;
_borderBottomRightRadius = -1; _borderBottomRightRadius = -1;
_backgroundColor = [super backgroundColor]; _backgroundColor = super.backgroundColor;
} }
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithCoder:unused) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:unused)
- (NSString *)accessibilityLabel - (NSString *)accessibilityLabel
{ {
@ -210,8 +210,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:unused)
baseInset.left += autoInset.left; baseInset.left += autoInset.left;
baseInset.right += autoInset.right; baseInset.right += autoInset.right;
} }
[scrollView setContentInset:baseInset]; scrollView.contentInset = baseInset;
[scrollView setScrollIndicatorInsets:baseInset]; scrollView.scrollIndicatorInsets = baseInset;
if (updateOffset) { if (updateOffset) {
// If we're adjusting the top inset, then let's also adjust the contentOffset so that the view // 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]; return [super react_updateClippedSubviewsWithClipRect:clipRect relativeToView:clipView];
} }
if ([_reactSubviews count] == 0) { if (_reactSubviews.count == 0) {
// Do nothing if we have no subviews // Do nothing if we have no subviews
return; return;
} }
@ -405,7 +405,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:unused)
// offscreen views. If _reactSubviews is nil, we can assume // offscreen views. If _reactSubviews is nil, we can assume
// that [self reactSubviews] and [self subviews] are the same // that [self reactSubviews] and [self subviews] are the same
return _reactSubviews ?: [self subviews]; return _reactSubviews ?: self.subviews;
} }
- (void)updateClippedSubviews - (void)updateClippedSubviews

View File

@ -51,7 +51,7 @@ RCT_EXPORT_MODULE()
- (dispatch_queue_t)methodQueue - (dispatch_queue_t)methodQueue
{ {
return [_bridge.uiManager methodQueue]; return _bridge.uiManager.methodQueue;
} }
- (UIView *)view - (UIView *)view

View File

@ -47,8 +47,8 @@ NSString *const RCTJSNavigationScheme = @"react-js-navigation";
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithFrame:(CGRect)frame) RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)goForward - (void)goForward
{ {
@ -127,11 +127,11 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
NSString *title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"]; NSString *title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
NSMutableDictionary *event = [[NSMutableDictionary alloc] initWithDictionary: @{ NSMutableDictionary *event = [[NSMutableDictionary alloc] initWithDictionary: @{
@"target": self.reactTag, @"target": self.reactTag,
@"url": url ? [url absoluteString] : @"", @"url": url ? url.absoluteString : @"",
@"loading" : @(_webView.loading), @"loading" : @(_webView.loading),
@"title": title, @"title": title,
@"canGoBack": @([_webView canGoBack]), @"canGoBack": @(_webView.canGoBack),
@"canGoForward" : @([_webView canGoForward]), @"canGoForward" : @(_webView.canGoForward),
}]; }];
return event; return event;
@ -148,7 +148,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
if (isTopFrame) { if (isTopFrame) {
NSMutableDictionary *event = [self baseEvent]; NSMutableDictionary *event = [self baseEvent];
[event addEntriesFromDictionary: @{ [event addEntriesFromDictionary: @{
@"url": [request.URL absoluteString], @"url": (request.URL).absoluteString,
@"navigationType": @(navigationType) @"navigationType": @(navigationType)
}]; }];
[_eventDispatcher sendInputEventWithName:@"loadingStart" body:event]; [_eventDispatcher sendInputEventWithName:@"loadingStart" body:event];
@ -172,7 +172,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
[event addEntriesFromDictionary: @{ [event addEntriesFromDictionary: @{
@"domain": error.domain, @"domain": error.domain,
@"code": @(error.code), @"code": @(error.code),
@"description": [error localizedDescription], @"description": error.localizedDescription,
}]; }];
[_eventDispatcher sendInputEventWithName:@"loadingError" body:event]; [_eventDispatcher sendInputEventWithName:@"loadingError" body:event];
} }

View File

@ -52,8 +52,8 @@
return self; return self;
} }
RCT_NOT_IMPLEMENTED(-initWithNibName:(NSString *)nn bundle:(NSBundle *)nb) RCT_NOT_IMPLEMENTED(- (instancetype)initWithNibName:(NSString *)nn bundle:(NSBundle *)nb)
RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder) RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
- (void)viewWillLayoutSubviews - (void)viewWillLayoutSubviews
{ {