Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Add debug tool to get shadowView from UIView
Browse files Browse the repository at this point in the history
Reviewed By: nicklockwood

Differential Revision: D3058618

fb-gh-sync-id: 8e6c0ad328fa767f43438c9461b8374d1279931b
shipit-source-id: 8e6c0ad328fa767f43438c9461b8374d1279931b
  • Loading branch information
javache authored and Facebook Github Bot 3 committed Mar 16, 2016
1 parent 0be6031 commit bebd9c4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,10 @@ - (void)_manageChildren:(NSNumber *)containerReactTag
[uiManager->_bridgeTransactionListeners addObject:view];
}
((NSMutableDictionary<NSNumber *, UIView *> *)viewRegistry)[reactTag] = view;

#if RCT_DEV
[view _DEBUG_setReactShadowView:shadowView];
#endif
}
}];
}
Expand Down
9 changes: 9 additions & 0 deletions React/Views/UIView+React.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import <UIKit/UIKit.h>

@class RCTShadowView;

#import "RCTComponent.h"

//TODO: let's try to eliminate this category if possible
Expand Down Expand Up @@ -49,4 +51,11 @@
- (void)reactDidMakeFirstResponder;
- (BOOL)reactRespondsToTouch:(UITouch *)touch;

/**
Tools for debugging
*/
#if RCT_DEV
@property (nonatomic, strong, setter=_DEBUG_setReactShadowView:) RCTShadowView *_DEBUG_reactShadowView;
#endif

@end
16 changes: 16 additions & 0 deletions React/Views/UIView+React.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#import "RCTAssert.h"
#import "RCTLog.h"
#import "RCTShadowView.h"

@implementation UIView (React)

Expand All @@ -26,6 +27,21 @@ - (void)setReactTag:(NSNumber *)reactTag
objc_setAssociatedObject(self, @selector(reactTag), reactTag, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

#if RCT_DEBUG

- (RCTShadowView *)_DEBUG_reactShadowView
{
return objc_getAssociatedObject(self, _cmd);
}

- (void)_DEBUG_setReactShadowView:(RCTShadowView *)shadowView
{
// Use assign to avoid keeping the shadowView alive it if no longer exists
objc_setAssociatedObject(self, @selector(_DEBUG_reactShadowView), shadowView, OBJC_ASSOCIATION_ASSIGN);
}

#endif

- (BOOL)isReactRootView
{
return RCTIsReactRootView(self.reactTag);
Expand Down

0 comments on commit bebd9c4

Please sign in to comment.