Skip to content

Commit

Permalink
Stop recursive double setting of default options (#5456)
Browse files Browse the repository at this point in the history
There is no need to call `setDefaultOptions` on the `childViewController` while iterating the `childViewControllers` as those will be passed recursively as `rootViewController` anyway and thus calling `setDefaultOptions` in the nested recursive call.
  • Loading branch information
danilobuerger authored and guyca committed Sep 5, 2019
1 parent b048581 commit d5c92b1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/ios/RNNDefaultOptionsHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
@implementation RNNDefaultOptionsHelper

+ (void)recrusivelySetDefaultOptions:(RNNNavigationOptions *)defaultOptions onRootViewController:(UIViewController *)rootViewController {
if ([rootViewController conformsToProtocol:@protocol(RNNLayoutProtocol)])
if ([rootViewController conformsToProtocol:@protocol(RNNLayoutProtocol)]) {
[((UIViewController<RNNLayoutProtocol> *)rootViewController) setDefaultOptions:defaultOptions];
}

for (UIViewController<RNNLayoutProtocol>* childViewController in rootViewController.childViewControllers) {
if ([childViewController conformsToProtocol:@protocol(RNNLayoutProtocol)]) {
[childViewController setDefaultOptions:defaultOptions];
}

[self recrusivelySetDefaultOptions:defaultOptions onRootViewController:childViewController];
}
}
Expand Down

0 comments on commit d5c92b1

Please sign in to comment.