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)");
#endif
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
RCTAssert(version.majorVersion == 8 || version.minorVersion >= 3, @"Tests should be run on iOS 8.3+, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
_runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp", nil);
}

View File

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

View File

@ -36,7 +36,7 @@
RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
#endif
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
RCTAssert(version.majorVersion == 8 || version.minorVersion >= 3, @"Snapshot tests should be run on iOS 8.3+, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
_runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp.ios", nil);
_runner.recordMode = NO;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -170,7 +170,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation,
// The 'ph://' prefix is used by FBMediaKit to differentiate between
// assets-library. It is prepended to the local ID so that it is in the
// form of an, NSURL which is what assets-library uses.
NSString *phAssetID = [imageTag substringFromIndex:[@"ph://" length]];
NSString *phAssetID = [imageTag substringFromIndex:@"ph://".length];
PHFetchResult *results = [PHAsset fetchAssetsWithLocalIdentifiers:@[phAssetID] options:nil];
if (results.count == 0) {
NSString *errorText = [NSString stringWithFormat:@"Failed to fetch PHAsset with local identifier %@ with no error message.", phAssetID];
@ -179,7 +179,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation,
return ^{};
}
PHAsset *asset = [results firstObject];
PHAsset *asset = results.firstObject;
PHImageRequestOptions *imageOptions = [PHImageRequestOptions new];

View File

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

View File

@ -22,13 +22,13 @@ RCT_EXPORT_MODULE()
- (BOOL)canHandleRequest:(NSURLRequest *)request
{
return [@[@"assets-library", @"ph"] containsObject:[request.URL.scheme lowercaseString]];
return [@[@"assets-library", @"ph"] containsObject:request.URL.scheme.lowercaseString];
}
- (id)sendRequest:(NSURLRequest *)request
withDelegate:(id<RCTURLRequestDelegate>)delegate
{
NSString *URLString = [request.URL absoluteString];
NSString *URLString = request.URL.absoluteString;
__block RCTImageLoaderCancellationBlock requestToken = nil;
requestToken = [_bridge.imageLoader loadImageWithTag:URLString callback:^(NSError *error, UIImage *image) {

View File

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

View File

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

View File

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

View File

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

View File

@ -47,7 +47,7 @@ RCT_EXPORT_MODULE()
- (BOOL)canHandleRequest:(NSURLRequest *)request
{
return [@[@"http", @"https", @"file"] containsObject:[request.URL.scheme lowercaseString]];
return [@[@"http", @"https", @"file"] containsObject:request.URL.scheme.lowercaseString];
}
- (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request

View File

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

View File

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

View File

@ -65,7 +65,7 @@
(CGBitmapInfo)kCGImageAlphaPremultipliedLast
);
CGFloat scaleFactor = [[UIScreen mainScreen] scale];
CGFloat scaleFactor = [UIScreen mainScreen].scale;
CGContextScaleCTM(referenceImageContext, 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) {
NSString *testName = NSStringFromSelector(_testSelector);
_snapshotCounter[testName] = [@([_snapshotCounter[testName] integerValue] + 1) stringValue];
_snapshotCounter[testName] = (@([_snapshotCounter[testName] integerValue] + 1)).stringValue;
NSError *error = nil;
BOOL success = [_controller compareSnapshotOfView:_view

View File

@ -55,7 +55,7 @@
return self;
}
RCT_NOT_IMPLEMENTED(-init)
RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (void)setRecordMode:(BOOL)recordMode
{
@ -109,7 +109,7 @@ RCT_NOT_IMPLEMENTED(-init)
[vc.view addSubview:rootView]; // Add as subview so it doesn't get resized
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
while ([date timeIntervalSinceNow] > 0 && testModule.status == RCTTestStatusPending && error == nil) {
while (date.timeIntervalSinceNow > 0 && testModule.status == RCTTestStatusPending && error == nil) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
}

View File

@ -34,8 +34,8 @@ static css_dim_t RCTMeasure(void *context, float width)
{
RCTShadowText *shadowText = (__bridge RCTShadowText *)context;
NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width];
NSLayoutManager *layoutManager = [textStorage.layoutManagers firstObject];
NSTextContainer *textContainer = [layoutManager.textContainers firstObject];
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
CGSize computedSize = [layoutManager usedRectForTextContainer:textContainer].size;
css_dim_t result;
@ -190,7 +190,7 @@ static css_dim_t RCTMeasure(void *context, float width)
[attributedString appendAttributedString:[shadowText _attributedStringWithFontFamily:fontFamily fontSize:fontSize fontWeight:fontWeight fontStyle:fontStyle letterSpacing:letterSpacing useBackgroundColor:YES]];
} else if ([child isKindOfClass:[RCTShadowRawText class]]) {
RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child;
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:[shadowRawText text] ?: @""]];
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
} else {
RCTLogError(@"<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
{
[attributedString enumerateAttribute:attribute inRange:NSMakeRange(0, [attributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
[attributedString enumerateAttribute:attribute inRange:NSMakeRange(0, attributedString.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
if (!value && attributeValue) {
[attributedString addAttribute:attribute value:attributeValue range:range];
}
@ -249,10 +249,10 @@ static css_dim_t RCTMeasure(void *context, float width)
}
// check for lineHeight on each of our children, update the max as we go (in self.lineHeight)
[attributedString enumerateAttribute:NSParagraphStyleAttributeName inRange:NSMakeRange(0, [attributedString length]) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
[attributedString enumerateAttribute:NSParagraphStyleAttributeName inRange:(NSRange){0, attributedString.length} options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
if (value) {
NSParagraphStyle *paragraphStyle = (NSParagraphStyle *)value;
CGFloat maximumLineHeight = round([paragraphStyle maximumLineHeight] / self.fontSizeMultiplier);
CGFloat maximumLineHeight = round(paragraphStyle.maximumLineHeight / self.fontSizeMultiplier);
if (maximumLineHeight > self.lineHeight) {
self.lineHeight = maximumLineHeight;
}
@ -305,13 +305,13 @@ static css_dim_t RCTMeasure(void *context, float width)
- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
{
[super insertReactSubview:subview atIndex:atIndex];
[self cssNode]->children_count = 0;
self.cssNode->children_count = 0;
}
- (void)removeReactSubview:(RCTShadowView *)subview
{
[super removeReactSubview:subview];
[self cssNode]->children_count = 0;
self.cssNode->children_count = 0;
}
- (void)setBackgroundColor:(UIColor *)backgroundColor
@ -348,7 +348,7 @@ RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection)
_allowFontScaling = allowFontScaling;
for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)child setAllowFontScaling:allowFontScaling];
((RCTShadowText *)child).allowFontScaling = allowFontScaling;
}
}
[self dirtyText];
@ -359,7 +359,7 @@ RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection)
_fontSizeMultiplier = fontSizeMultiplier;
for (RCTShadowView *child in [self reactSubviews]) {
if ([child isKindOfClass:[RCTShadowText class]]) {
[(RCTShadowText *)child setFontSizeMultiplier:fontSizeMultiplier];
((RCTShadowText *)child).fontSizeMultiplier = fontSizeMultiplier;
}
}
[self dirtyText];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@
@implementation RCTJavaScriptLoader
RCT_NOT_IMPLEMENTED(-init)
RCT_NOT_IMPLEMENTED(- (instancetype)init)
+ (void)loadBundleAtURL:(NSURL *)scriptURL onComplete:(RCTSourceLoadBlock)onComplete
{
@ -24,7 +24,7 @@ RCT_NOT_IMPLEMENTED(-init)
scriptURL = [RCTConvert NSURL:scriptURL.absoluteString];
if (!scriptURL ||
([scriptURL isFileURL] && ![[NSFileManager defaultManager] fileExistsAtPath:scriptURL.path])) {
(scriptURL.fileURL && ![[NSFileManager defaultManager] fileExistsAtPath:scriptURL.path])) {
NSError *error = [NSError errorWithDomain:@"JavaScriptLoader" code:1 userInfo:@{
NSLocalizedDescriptionKey: scriptURL ? [NSString stringWithFormat:@"Script at '%@' could not be found.", scriptURL] : @"No script URL provided"
}];
@ -37,11 +37,11 @@ RCT_NOT_IMPLEMENTED(-init)
// Handle general request errors
if (error) {
if ([[error domain] isEqualToString:NSURLErrorDomain]) {
NSString *desc = [@"Could not connect to development server. Ensure node server is running and available on the same network - run 'npm start' from react-native root\n\nURL: " stringByAppendingString:[scriptURL absoluteString]];
if ([error.domain isEqualToString:NSURLErrorDomain]) {
NSString *desc = [@"Could not connect to development server. Ensure node server is running and available on the same network - run 'npm start' from react-native root\n\nURL: " stringByAppendingString:scriptURL.absoluteString];
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: desc,
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
NSLocalizedFailureReasonErrorKey: error.localizedDescription,
NSUnderlyingErrorKey: error,
};
error = [NSError errorWithDomain:@"JSServer"
@ -63,7 +63,7 @@ RCT_NOT_IMPLEMENTED(-init)
NSString *rawText = [[NSString alloc] initWithData:data encoding:encoding];
// Handle HTTP errors
if ([response isKindOfClass:[NSHTTPURLResponse class]] && [(NSHTTPURLResponse *)response statusCode] != 200) {
if ([response isKindOfClass:[NSHTTPURLResponse class]] && ((NSHTTPURLResponse *)response).statusCode != 200) {
NSDictionary *userInfo;
NSDictionary *errorDetails = RCTJSONParse(rawText, nil);
if ([errorDetails isKindOfClass:[NSDictionary class]] &&
@ -84,7 +84,7 @@ RCT_NOT_IMPLEMENTED(-init)
userInfo = @{NSLocalizedDescriptionKey: rawText};
}
error = [NSError errorWithDomain:@"JSServer"
code:[(NSHTTPURLResponse *)response statusCode]
code:((NSHTTPURLResponse *)response).statusCode
userInfo:userInfo];
onComplete(error, nil);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,7 +60,7 @@
return self;
}
RCT_NOT_IMPLEMENTED(-initWithTarget:(id)target action:(SEL)action)
RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action)
typedef NS_ENUM(NSInteger, RCTTouchEventType) {
RCTTouchEventTypeStart,
@ -224,7 +224,7 @@ static BOOL RCTAnyTouchesChanged(NSSet *touches)
{
// If gesture just recognized, send all touches to JS as if they just began.
if (self.state == UIGestureRecognizerStateBegan) {
[self _updateAndDispatchTouches:[_nativeTouches set] eventName:@"topTouchStart" originatingTime:0];
[self _updateAndDispatchTouches:_nativeTouches.set eventName:@"topTouchStart" originatingTime:0];
// We store this flag separately from `state` because after a gesture is
// recognized, its `state` changes immediately but its action (this

View File

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

View File

@ -41,7 +41,7 @@
@property (nonatomic, assign, readonly) JSGlobalContextRef ctx;
- (instancetype)initWithJSContext:(JSGlobalContextRef)context;
- (instancetype)initWithJSContext:(JSGlobalContextRef)context NS_DESIGNATED_INITIALIZER;
@end
@ -59,6 +59,8 @@
return self;
}
RCT_NOT_IMPLEMENTED(-(instancetype)init)
- (BOOL)isValid
{
return _ctx != NULL;
@ -195,7 +197,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
{
@autoreleasepool {
// copy thread name to pthread name
pthread_setname_np([[[NSThread currentThread] name] UTF8String]);
pthread_setname_np([NSThread currentThread].name.UTF8String);
// Set up a dummy runloop source to avoid spinning
CFRunLoopSourceContext noSpinCtx = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
@ -204,7 +206,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
CFRelease(noSpinSource);
// run the run loop
while (kCFRunLoopRunStopped != CFRunLoopRunInMode(kCFRunLoopDefaultMode, [[NSDate distantFuture] timeIntervalSinceReferenceDate], NO)) {
while (kCFRunLoopRunStopped != CFRunLoopRunInMode(kCFRunLoopDefaultMode, ((NSDate *)[NSDate distantFuture]).timeIntervalSinceReferenceDate, NO)) {
RCTAssert(NO, @"not reached assertion"); // runloop spun. that's bad.
}
}
@ -215,8 +217,8 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
NSThread *javaScriptThread = [[NSThread alloc] initWithTarget:[self class]
selector:@selector(runRunLoopThread)
object:nil];
[javaScriptThread setName:@"com.facebook.React.JavaScript"];
[javaScriptThread setThreadPriority:[[NSThread mainThread] threadPriority]];
javaScriptThread.name = @"com.facebook.React.JavaScript";
javaScriptThread.threadPriority = [NSThread mainThread].threadPriority;
[javaScriptThread start];
return [self initWithJavaScriptThread:javaScriptThread globalContextRef:NULL];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ RCT_REMAP_VIEW_PROPERTY(badge, barItem.badgeValue, NSString);
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
{
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;
view.barItem.imageInsets = [view.barItem.title length] ? UIEdgeInsetsZero : (UIEdgeInsets){6, 0, -6, 0};
view.barItem.imageInsets = view.barItem.title.length ? UIEdgeInsetsZero : (UIEdgeInsets){6, 0, -6, 0};
}
@end

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

View File

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

View File

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

View File

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