clean up NSClassFromString in Libraries/

Reviewed By: adamjernst

Differential Revision: D3794507

fbshipit-source-id: 5f6f8d3ccfcb8a7339532ca1c092750b85d622d2
This commit is contained in:
Scott Wolchok 2016-08-30 17:45:38 -07:00 committed by Facebook Github Bot 3
parent 16f76d4407
commit 8a8ac771b1
2 changed files with 8 additions and 5 deletions

View File

@ -11,6 +11,7 @@
#import <mach/mach_time.h>
#import <objc/message.h>
#import <objc/runtime.h>
#import <UIKit/UIKit.h>
@ -434,7 +435,7 @@ BOOL RCTRunningInTestEnvironment(void)
static BOOL isTestEnvironment = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
isTestEnvironment = NSClassFromString(@"SenTestCase") || NSClassFromString(@"XCTest");
isTestEnvironment = objc_lookUpClass("SenTestCase") || objc_lookUpClass("XCTest");
});
return isTestEnvironment;
}

View File

@ -9,6 +9,8 @@
#import "RCTDevMenu.h"
#import <objc/runtime.h>
#import "RCTAssert.h"
#import "RCTBridge+Private.h"
#import "RCTDefines.h"
@ -255,7 +257,7 @@ RCT_EXPORT_MODULE()
// TODO: Move non-UI logic into separate RCTDevSettings module
- (void)connectPackager
{
Class webSocketManagerClass = NSClassFromString(@"RCTWebSocketManager");
Class webSocketManagerClass = objc_lookUpClass("RCTWebSocketManager");
id<RCTWebSocketProxy> webSocketManager = (id <RCTWebSocketProxy>)[webSocketManagerClass sharedInstance];
NSURL *url = [self packagerURL];
if (url) {
@ -281,7 +283,7 @@ RCT_EXPORT_MODULE()
if ([target isEqualToString:@"bridge"]) {
if ([action isEqualToString:@"reload"]) {
if ([options[@"debug"] boolValue]) {
_bridge.executorClass = NSClassFromString(@"RCTWebSocketExecutor");
_bridge.executorClass = objc_lookUpClass("RCTWebSocketExecutor");
}
[_bridge reload];
}
@ -453,7 +455,7 @@ RCT_EXPORT_MODULE()
[weakSelf reload];
}]];
Class jsDebuggingExecutorClass = NSClassFromString(@"RCTWebSocketExecutor");
Class jsDebuggingExecutorClass = objc_lookUpClass("RCTWebSocketExecutor");
if (!jsDebuggingExecutorClass) {
[items addObject:[RCTDevMenuItem buttonItemWithTitle:[NSString stringWithFormat:@"%@ Debugger Unavailable", _webSocketExecutorName] handler:^{
UIAlertView *alert = RCTAlertView(
@ -637,7 +639,7 @@ RCT_EXPORT_METHOD(reload)
// needed to prevent overriding a custom executor with the default if a
// custom executor has been set directly on the bridge
if (executorClass == Nil &&
_bridge.executorClass != NSClassFromString(@"RCTWebSocketExecutor")) {
_bridge.executorClass != objc_lookUpClass("RCTWebSocketExecutor")) {
return;
}