Last active
August 29, 2015 13:58
-
-
Save JaviSoto/9984349 to your computer and use it in GitHub Desktop.
-[UIViewController viewWillAppear:] from UIView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tapIntoViewControllerWillAppear { | |
@weakify(self); | |
[[[[[[[RACSignal interval:0.1f onScheduler:[RACScheduler mainThreadScheduler]] takeUntil:self.rac_willDeallocSignal] flattenMap:^RACStream *(id value) { | |
@strongify(self); | |
return [RACSignal return:self.pb_viewController]; | |
}] ignore:nil] take:1] flattenMap:^RACStream *(UIViewController *viewController) { | |
return [viewController rac_signalForSelector:@selector(viewWillAppear:)]; | |
}] subscribeNext:^(id x) { | |
@strongify(self); | |
// Do something | |
}]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UIView (PBViewControllerFromView) | |
- (UIViewController *)pb_viewController { | |
return [self valueForKey:@"_viewDelegate"] ?: self.superview.pb_viewController; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment