Skip to content

RNAppGlobals lines no longer need to be added to AppDelegate to use reactModuleForCell #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RNTableView/RNAppGlobals.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ @implementation RNAppGlobals
@synthesize appBridge;

+ (id)sharedInstance {
NSLog(@"RNAppGlobals is deprecated/no longer needed and will be removed soon");

static RNAppGlobals *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Expand Down
4 changes: 2 additions & 2 deletions RNTableView/RNTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <UIKit/UIKit.h>
@class RCTEventDispatcher;
@class RCTBridge;

@protocol RNTableViewDatasource <NSObject>

Expand All @@ -21,7 +21,7 @@

@interface RNTableView : UIView

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;

@property (nonatomic, copy) NSMutableArray *sections;
@property (nonatomic, copy) NSArray *additionalItems;
Expand Down
17 changes: 11 additions & 6 deletions RNTableView/RNTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#import "RNTableFooterView.h"
#import "RNTableHeaderView.h"
#import "RNReactModuleCell.h"
#import "RNAppGlobals.h"

@interface RNTableView()<UITableViewDataSource, UITableViewDelegate> {
id<RNTableViewDatasource> datasource;
Expand Down Expand Up @@ -70,13 +69,19 @@ - (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex
}
}

- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{
RCTAssertParam(eventDispatcher);
- (instancetype)initWithBridge:(RCTBridge *)bridge {
RCTAssertParam(bridge);
RCTAssertParam(bridge.eventDispatcher);

if ((self = [super initWithFrame:CGRectZero])) {
_bridge = [[RNAppGlobals sharedInstance] appBridge];
_eventDispatcher = eventDispatcher;
_eventDispatcher = bridge.eventDispatcher;

_bridge = bridge;
while ([_bridge respondsToSelector:NSSelectorFromString(@"parentBridge")]
&& [_bridge valueForKey:@"parentBridge"]) {
_bridge = [_bridge valueForKey:@"parentBridge"];
}

_cellHeight = 44;
_cells = [NSMutableArray array];
_autoFocus = YES;
Expand Down
2 changes: 1 addition & 1 deletion RNTableView/RNTableViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @implementation RNTableViewManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [[RNTableView alloc] initWithEventDispatcher:self.bridge.eventDispatcher];
return [[RNTableView alloc] initWithBridge:self.bridge];
}

- (NSArray *)customDirectEventTypes
Expand Down
1 change: 0 additions & 1 deletion examples/TableViewDemo/iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

//Save main bridge so that RNTableView could access our bridge to create its RNReactModuleCells
[[RNAppGlobals sharedInstance] setAppBridge:rootView.bridge];


self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [[UIViewController alloc] init];
Expand Down