Skip to content

Commit 88e0bbc

Browse files
committed
Ran Convert > To Modern Objective C Syntax
1 parent a57353b commit 88e0bbc

80 files changed

Lines changed: 247 additions & 246 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Examples/UIExplorer/UIExplorerIntegrationTests/IntegrationTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ - (void)setUp
2929
RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
3030
#endif
3131

32-
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
32+
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
3333
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);
3434
_runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerIntegrationTests/js/IntegrationTestsApp", nil);
3535
}

Examples/UIExplorer/UIExplorerIntegrationTests/RCTUIManagerScenarioTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ - (void)setUp
5050
// Register 20 views to use in the tests
5151
for (NSInteger i = 1; i <= 20; i++) {
5252
UIView *registeredView = [UIView new];
53-
[registeredView setReactTag:@(i)];
53+
registeredView.reactTag = @(i);
5454
_uiManager.viewRegistry[i] = registeredView;
5555
}
5656
}
@@ -92,7 +92,7 @@ - (void)testManagingChildrenToRemoveViews
9292

9393
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
9494
for (NSNumber *index in removeAtIndices) {
95-
NSNumber *reactTag = @([index integerValue] + 2);
95+
NSNumber *reactTag = @(index.integerValue + 2);
9696
[removedViews addObject:_uiManager.viewRegistry[reactTag]];
9797
}
9898
for (NSInteger i = 2; i < 20; i++) {

Examples/UIExplorer/UIExplorerIntegrationTests/UIExplorerSnapshotTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ - (void)setUp
3636
RCTAssert(NO, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
3737
#endif
3838

39-
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
39+
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
4040
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);
4141
_runner = RCTInitRunnerForApp(@"Examples/UIExplorer/UIExplorerApp.ios", nil);
4242
_runner.recordMode = NO;

Examples/UIExplorer/UIExplorerUnitTests/RCTUIManagerTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ - (void)setUp
4949
// Register 20 views to use in the tests
5050
for (NSInteger i = 1; i <= 20; i++) {
5151
UIView *registeredView = [UIView new];
52-
[registeredView setReactTag:@(i)];
52+
registeredView.reactTag = @(i);
5353
_uiManager.viewRegistry[i] = registeredView;
5454
}
5555
}
@@ -91,7 +91,7 @@ - (void)testManagingChildrenToRemoveViews
9191

9292
NSArray *removeAtIndices = @[@0, @4, @8, @12, @16];
9393
for (NSNumber *index in removeAtIndices) {
94-
NSNumber *reactTag = @([index integerValue] + 2);
94+
NSNumber *reactTag = @(index.integerValue + 2);
9595
[removedViews addObject:_uiManager.viewRegistry[reactTag]];
9696
}
9797
for (NSInteger i = 2; i < 20; i++) {

Libraries/ActionSheetIOS/RCTActionSheetManager.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ - (dispatch_queue_t)methodQueue
6060

6161
_callbacks[RCTKeyForInstance(actionSheet)] = successCallback;
6262

63-
UIWindow *appWindow = [[[UIApplication sharedApplication] delegate] window];
63+
UIWindow *appWindow = [UIApplication sharedApplication].delegate.window;
6464
if (appWindow == nil) {
6565
RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options);
6666
return;
@@ -81,12 +81,12 @@ - (dispatch_queue_t)methodQueue
8181
if (URL) {
8282
[items addObject:URL];
8383
}
84-
if ([items count] == 0) {
84+
if (items.count == 0) {
8585
failureCallback(@[@"No `url` or `message` to share"]);
8686
return;
8787
}
8888
UIActivityViewController *share = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
89-
UIViewController *ctrl = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
89+
UIViewController *ctrl = [UIApplication sharedApplication].delegate.window.rootViewController;
9090

9191
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
9292

@@ -126,7 +126,7 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
126126
RCTLogWarn(@"No callback registered for action sheet: %@", actionSheet.title);
127127
}
128128

129-
[[[[UIApplication sharedApplication] delegate] window] makeKeyWindow];
129+
[[UIApplication sharedApplication].delegate.window makeKeyWindow];
130130
}
131131

132132
#pragma mark Private

Libraries/Geolocation/RCTLocationObserver.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ - (void)timeout:(NSTimer *)timer
252252
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
253253
{
254254
// Create event
255-
CLLocation *location = [locations lastObject];
255+
CLLocation *location = locations.lastObject;
256256
_lastLocationEvent = @{
257257
@"coords": @{
258258
@"latitude": @(location.coordinate.latitude),

Libraries/Image/RCTCameraRollManager.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,20 @@ @implementation RCTCameraRollManager
3434
errorCallback(loadError);
3535
return;
3636
}
37-
[_bridge.assetsLibrary writeImageToSavedPhotosAlbum:[loadedImage CGImage] metadata:nil completionBlock:^(NSURL *assetURL, NSError *saveError) {
37+
[_bridge.assetsLibrary writeImageToSavedPhotosAlbum:loadedImage.CGImage metadata:nil completionBlock:^(NSURL *assetURL, NSError *saveError) {
3838
if (saveError) {
3939
RCTLogWarn(@"Error saving cropped image: %@", saveError);
4040
errorCallback(saveError);
4141
} else {
42-
successCallback(@[[assetURL absoluteString]]);
42+
successCallback(@[assetURL.absoluteString]);
4343
}
4444
}];
4545
}];
4646
}
4747

4848
- (void)callCallback:(RCTResponseSenderBlock)callback withAssets:(NSArray *)assets hasNextPage:(BOOL)hasNextPage
4949
{
50-
if (![assets count]) {
50+
if (!assets.count) {
5151
callback(@[@{
5252
@"edges": assets,
5353
@"page_info": @{
@@ -109,14 +109,14 @@ - (void)callCallback:(RCTResponseSenderBlock)callback withAssets:(NSArray *)asse
109109

110110
[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stopAssets) {
111111
if (result) {
112-
NSString *uri = [(NSURL *)[result valueForProperty:ALAssetPropertyAssetURL] absoluteString];
112+
NSString *uri = ((NSURL *)[result valueForProperty:ALAssetPropertyAssetURL]).absoluteString;
113113
if (afterCursor && !foundAfter) {
114114
if ([afterCursor isEqualToString:uri]) {
115115
foundAfter = YES;
116116
}
117117
return; // Skip until we get to the first one
118118
}
119-
if (first == [assets count]) {
119+
if (first == assets.count) {
120120
*stopAssets = YES;
121121
*stopGroups = YES;
122122
hasNextPage = YES;
@@ -138,7 +138,7 @@ - (void)callCallback:(RCTResponseSenderBlock)callback withAssets:(NSArray *)asse
138138
@"width": @(dimensions.width),
139139
@"isStored": @YES,
140140
},
141-
@"timestamp": @([date timeIntervalSince1970]),
141+
@"timestamp": @(date.timeIntervalSince1970),
142142
@"location": loc ?
143143
@{
144144
@"latitude": @(loc.coordinate.latitude),

Libraries/Image/RCTGIFImage.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
return nil;
8686
}
8787

88-
if (![URL isFileURL]) {
88+
if (!URL.fileURL) {
8989
RCTLogError(@"Loading remote image URLs synchronously is a really bad idea.");
9090
return nil;
9191
}

Libraries/Image/RCTImageLoader.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ - (RCTImageLoaderCancellationBlock)loadImageWithTag:(NSString *)imageTag
170170
// The 'ph://' prefix is used by FBMediaKit to differentiate between
171171
// assets-library. It is prepended to the local ID so that it is in the
172172
// form of an, NSURL which is what assets-library uses.
173-
NSString *phAssetID = [imageTag substringFromIndex:[@"ph://" length]];
173+
NSString *phAssetID = [imageTag substringFromIndex:@"ph://".length];
174174
PHFetchResult *results = [PHAsset fetchAssetsWithLocalIdentifiers:@[phAssetID] options:nil];
175175
if (results.count == 0) {
176176
NSString *errorText = [NSString stringWithFormat:@"Failed to fetch PHAsset with local identifier %@ with no error message.", phAssetID];
@@ -179,7 +179,7 @@ - (RCTImageLoaderCancellationBlock)loadImageWithTag:(NSString *)imageTag
179179
return ^{};
180180
}
181181

182-
PHAsset *asset = [results firstObject];
182+
PHAsset *asset = results.firstObject;
183183

184184
PHImageRequestOptions *imageOptions = [PHImageRequestOptions new];
185185

Libraries/Image/RCTImagePickerManager.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ - (instancetype)init
5353
successCallback:(RCTResponseSenderBlock)callback
5454
cancelCallback:(RCTResponseSenderBlock)cancelCallback)
5555
{
56-
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
56+
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
5757
UIViewController *rootViewController = keyWindow.rootViewController;
5858

5959
UIImagePickerController *imagePicker = [UIImagePickerController new];
@@ -75,7 +75,7 @@ - (instancetype)init
7575
successCallback:(RCTResponseSenderBlock)callback
7676
cancelCallback:(RCTResponseSenderBlock)cancelCallback)
7777
{
78-
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
78+
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
7979
UIViewController *rootViewController = keyWindow.rootViewController;
8080

8181
UIImagePickerController *imagePicker = [UIImagePickerController new];
@@ -109,7 +109,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker
109109
[_pickerCallbacks removeObjectAtIndex:index];
110110
[_pickerCancelCallbacks removeObjectAtIndex:index];
111111

112-
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
112+
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
113113
UIViewController *rootViewController = keyWindow.rootViewController;
114114
[rootViewController dismissViewControllerAnimated:YES completion:nil];
115115

@@ -125,7 +125,7 @@ - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
125125
[_pickerCallbacks removeObjectAtIndex:index];
126126
[_pickerCancelCallbacks removeObjectAtIndex:index];
127127

128-
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
128+
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
129129
UIViewController *rootViewController = keyWindow.rootViewController;
130130
[rootViewController dismissViewControllerAnimated:YES completion:nil];
131131

0 commit comments

Comments
 (0)