Skip to content

Commit

Permalink
clean up NSClassFromString in Libraries/
Browse files Browse the repository at this point in the history
Reviewed By: adamjernst

Differential Revision: D3794507

fbshipit-source-id: 5f6f8d3ccfcb8a7339532ca1c092750b85d622d2
  • Loading branch information
swolchok authored and Facebook Github Bot 3 committed Aug 31, 2016
1 parent 16f76d4 commit 8a8ac77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion React/Base/RCTUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#import <mach/mach_time.h>
#import <objc/message.h>
#import <objc/runtime.h>

#import <UIKit/UIKit.h>

Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions React/Modules/RCTDevMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import "RCTDevMenu.h"

#import <objc/runtime.h>

#import "RCTAssert.h"
#import "RCTBridge+Private.h"
#import "RCTDefines.h"
Expand Down Expand Up @@ -255,7 +257,7 @@ - (NSURL *)packagerURL
// 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) {
Expand All @@ -281,7 +283,7 @@ - (void)processTarget:(NSString *)target action:(NSString *)action options:(NSDi
if ([target isEqualToString:@"bridge"]) {
if ([action isEqualToString:@"reload"]) {
if ([options[@"debug"] boolValue]) {
_bridge.executorClass = NSClassFromString(@"RCTWebSocketExecutor");
_bridge.executorClass = objc_lookUpClass("RCTWebSocketExecutor");
}
[_bridge reload];
}
Expand Down Expand Up @@ -453,7 +455,7 @@ - (void)addItem:(RCTDevMenuItem *)item
[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(
Expand Down Expand Up @@ -637,7 +639,7 @@ - (void)setExecutorClass:(Class)executorClass
// 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;
}

Expand Down

0 comments on commit 8a8ac77

Please sign in to comment.