Update ReactExample Objective-C to 4-space indentation

This commit is contained in:
Scott Kyle 2015-10-28 10:53:30 -07:00
parent 5edeefbb17
commit af9e7e8b4c
4 changed files with 72 additions and 73 deletions

View File

@ -349,9 +349,9 @@
027798471BBB2F1000C96559 /* ReactExampleTests */, 027798471BBB2F1000C96559 /* ReactExampleTests */,
83CBBA001A601CBA00E9B192 /* Products */, 83CBBA001A601CBA00E9B192 /* Products */,
); );
indentWidth = 2; indentWidth = 4;
sourceTree = "<group>"; sourceTree = "<group>";
tabWidth = 2; tabWidth = 4;
}; };
83CBBA001A601CBA00E9B192 /* Products */ = { 83CBBA001A601CBA00E9B192 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
@ -411,7 +411,7 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0700; LastUpgradeCheck = 0700;
ORGANIZATIONNAME = Facebook; ORGANIZATIONNAME = Realm;
TargetAttributes = { TargetAttributes = {
027798451BBB2F1000C96559 = { 027798451BBB2F1000C96559 = {
CreatedOnToolsVersion = 7.0.1; CreatedOnToolsVersion = 7.0.1;

View File

@ -19,47 +19,46 @@
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
{ {
if (test(view)) { if (test(view)) {
return YES; return YES;
}
for (UIView *subview in [view subviews]) {
if ([self findSubviewInView:subview matching:test]) {
return YES;
} }
} for (UIView *subview in [view subviews]) {
return NO; if ([self findSubviewInView:subview matching:test]) {
return YES;
}
}
return NO;
} }
- (void)testLaunched - (void)testLaunched
{ {
UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO; BOOL foundElement = NO;
__block NSString *redboxError = nil; __block NSString *redboxError = nil;
RCTSetLogFunction(^(RCTLogLevel level, NSString *fileName, NSNumber *lineNumber, NSString *message) { RCTSetLogFunction(^(RCTLogLevel level, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) { if (level >= RCTLogLevelError) {
redboxError = message; redboxError = message;
}
});
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
return YES;
}
return NO;
}];
} }
});
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { RCTSetLogFunction(RCTDefaultLogFunction);
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { //XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
return YES;
}
return NO;
}];
}
RCTSetLogFunction(RCTDefaultLogFunction);
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
//XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
} }
@end @end

View File

@ -10,47 +10,47 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{ {
NSURL *jsCodeLocation; NSURL *jsCodeLocation;
/** /**
* Loading JavaScript code - uncomment the one you want. * Loading JavaScript code - uncomment the one you want.
* *
* OPTION 1 * OPTION 1
* Load from development server. Start the server from the repository root: * Load from development server. Start the server from the repository root:
* *
* $ npm start * $ npm start
* *
* To run on device, change `localhost` to the IP address of your computer * To run on device, change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the * (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are * `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network. * on the same Wi-Fi network.
*/ */
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios"]; jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios"];
/** /**
* OPTION 2 * OPTION 2
* Load from pre-bundled file on disk. To re-generate the static bundle * Load from pre-bundled file on disk. To re-generate the static bundle
* from the root of your project directory, run * from the root of your project directory, run
* *
* $ react-native bundle --minify * $ react-native bundle --minify
* *
* see http://facebook.github.io/react-native/docs/runningondevice.html * see http://facebook.github.io/react-native/docs/runningondevice.html
*/ */
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"ReactExample" moduleName:@"ReactExample"
initialProperties:nil initialProperties:nil
launchOptions:launchOptions]; launchOptions:launchOptions];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [[UIViewController alloc] init]; UIViewController *rootViewController = [[UIViewController alloc] init];
rootViewController.view = rootView; rootViewController.view = rootView;
self.window.rootViewController = rootViewController; self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
return YES; return YES;
} }
@end @end

View File

@ -12,7 +12,7 @@
#import "AppDelegate.h" #import "AppDelegate.h"
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
@autoreleasepool { @autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
} }
} }