зеркало из https://github.com/github/Rebel.git
Merge pull request #144 from github/bye-bye-rblviewcontroller
Remove RBLViewController and its NSView category.
This commit is contained in:
Коммит
23ff1939ec
|
@ -31,10 +31,6 @@
|
|||
AB61F63716373FE000DD5D2C /* RBLTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = AB61F63516373FE000DD5D2C /* RBLTableCellView.m */; };
|
||||
AB61F6D41638370900DD5D2C /* NSApplication+RBLBlockAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = AB61F6D21638370900DD5D2C /* NSApplication+RBLBlockAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
AB61F6D51638370900DD5D2C /* NSApplication+RBLBlockAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = AB61F6D31638370900DD5D2C /* NSApplication+RBLBlockAdditions.m */; };
|
||||
B85EE8DE163ECA8C00265870 /* RBLViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B85EE8DC163ECA8C00265870 /* RBLViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B85EE8DF163ECA8C00265870 /* RBLViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B85EE8DD163ECA8C00265870 /* RBLViewController.m */; };
|
||||
B85EE8E9163ECF4C00265870 /* NSView+RBLViewControllerAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B85EE8E7163ECF4B00265870 /* NSView+RBLViewControllerAdditions.h */; };
|
||||
B85EE8EA163ECF4C00265870 /* NSView+RBLViewControllerAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B85EE8E8163ECF4C00265870 /* NSView+RBLViewControllerAdditions.m */; };
|
||||
B85EE8ED163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B85EE8EB163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.h */; };
|
||||
B85EE8EE163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B85EE8EC163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.m */; };
|
||||
BE17699A1975D93900EE78ED /* libSpecta-OSX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BE1769991975D93900EE78ED /* libSpecta-OSX.a */; };
|
||||
|
@ -117,10 +113,6 @@
|
|||
AB61F63516373FE000DD5D2C /* RBLTableCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBLTableCellView.m; sourceTree = "<group>"; };
|
||||
AB61F6D21638370900DD5D2C /* NSApplication+RBLBlockAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSApplication+RBLBlockAdditions.h"; sourceTree = "<group>"; };
|
||||
AB61F6D31638370900DD5D2C /* NSApplication+RBLBlockAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSApplication+RBLBlockAdditions.m"; sourceTree = "<group>"; };
|
||||
B85EE8DC163ECA8C00265870 /* RBLViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBLViewController.h; sourceTree = "<group>"; };
|
||||
B85EE8DD163ECA8C00265870 /* RBLViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBLViewController.m; sourceTree = "<group>"; };
|
||||
B85EE8E7163ECF4B00265870 /* NSView+RBLViewControllerAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+RBLViewControllerAdditions.h"; sourceTree = "<group>"; };
|
||||
B85EE8E8163ECF4C00265870 /* NSView+RBLViewControllerAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+RBLViewControllerAdditions.m"; sourceTree = "<group>"; };
|
||||
B85EE8EB163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+RBObjectSizzlingAdditions.h"; sourceTree = "<group>"; };
|
||||
B85EE8EC163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+RBObjectSizzlingAdditions.m"; sourceTree = "<group>"; };
|
||||
BE1769991975D93900EE78ED /* libSpecta-OSX.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libSpecta-OSX.a"; path = "External/specta/build/Debug/libSpecta-OSX.a"; sourceTree = "<group>"; };
|
||||
|
@ -235,8 +227,6 @@
|
|||
306A81DA1601C7A300BF45F3 /* RBLPopover.m */,
|
||||
AB61F63416373FE000DD5D2C /* RBLTableCellView.h */,
|
||||
AB61F63516373FE000DD5D2C /* RBLTableCellView.m */,
|
||||
B85EE8DC163ECA8C00265870 /* RBLViewController.h */,
|
||||
B85EE8DD163ECA8C00265870 /* RBLViewController.m */,
|
||||
AB10DB4B166EA9CA00AB7AB1 /* RBLScrollView.h */,
|
||||
AB10DB4C166EA9CA00AB7AB1 /* RBLScrollView.m */,
|
||||
303DEF4216D2B88700BD65C4 /* RBLShadowedTextFieldCell.h */,
|
||||
|
@ -272,8 +262,6 @@
|
|||
D0410EAA15C61895003A3203 /* NSTextView+RBLAntialiasingAdditions.m */,
|
||||
D04CBFC615F6D87B004A5BCC /* NSView+RBLAnimationAdditions.h */,
|
||||
D04CBFC715F6D87B004A5BCC /* NSView+RBLAnimationAdditions.m */,
|
||||
B85EE8E7163ECF4B00265870 /* NSView+RBLViewControllerAdditions.h */,
|
||||
B85EE8E8163ECF4C00265870 /* NSView+RBLViewControllerAdditions.m */,
|
||||
B85EE8EB163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.h */,
|
||||
B85EE8EC163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.m */,
|
||||
0396050816E2DBA7007A5542 /* NSView+RBLAlignmentAdditions.h */,
|
||||
|
@ -476,11 +464,9 @@
|
|||
D0E91C581603CC7600D23E93 /* RBLClipView.h in Headers */,
|
||||
D011FD5E16239A8600A27946 /* NSImage+RBLResizableImageAdditions.h in Headers */,
|
||||
AB61F63616373FE000DD5D2C /* RBLTableCellView.h in Headers */,
|
||||
B85EE8DE163ECA8C00265870 /* RBLViewController.h in Headers */,
|
||||
F64F8DEA1797E1F400082A3F /* RBLSlidingContainerView.h in Headers */,
|
||||
F6A562C01797DC5A00B651C0 /* RBLExpandingContainerView.h in Headers */,
|
||||
D4559AE81934C2910051A6BE /* RBLScrolling.h in Headers */,
|
||||
B85EE8E9163ECF4C00265870 /* NSView+RBLViewControllerAdditions.h in Headers */,
|
||||
B85EE8ED163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.h in Headers */,
|
||||
AB61F6D41638370900DD5D2C /* NSApplication+RBLBlockAdditions.h in Headers */,
|
||||
88347E6A16F213C500872A0A /* RBLHTMLView.h in Headers */,
|
||||
|
@ -600,9 +586,7 @@
|
|||
D011FD5F16239A8600A27946 /* NSImage+RBLResizableImageAdditions.m in Sources */,
|
||||
AB61F63716373FE000DD5D2C /* RBLTableCellView.m in Sources */,
|
||||
F64F8DEB1797E1F400082A3F /* RBLSlidingContainerView.m in Sources */,
|
||||
B85EE8DF163ECA8C00265870 /* RBLViewController.m in Sources */,
|
||||
D4559AE91934C2910051A6BE /* RBLScrolling.m in Sources */,
|
||||
B85EE8EA163ECF4C00265870 /* NSView+RBLViewControllerAdditions.m in Sources */,
|
||||
B85EE8EE163EE15800265870 /* NSObject+RBObjectSizzlingAdditions.m in Sources */,
|
||||
AB61F6D51638370900DD5D2C /* NSApplication+RBLBlockAdditions.m in Sources */,
|
||||
AB10DB4E166EA9CA00AB7AB1 /* RBLScrollView.m in Sources */,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
//
|
||||
// NSView+NSView_RBLViewControllerAdditions.h
|
||||
// Rebel
|
||||
//
|
||||
// Created by Colin Wheeler on 10/29/12.
|
||||
// Copyright (c) 2012 GitHub. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSView (NSView_RBLViewControllerAdditions)
|
||||
|
||||
@property (nonatomic, assign) IBOutlet NSViewController *rbl_viewController;
|
||||
|
||||
@end
|
|
@ -1,147 +0,0 @@
|
|||
//
|
||||
// NSView+NSView_RBLViewControllerAdditions.m
|
||||
// Rebel
|
||||
//
|
||||
// Created by Colin Wheeler on 10/29/12.
|
||||
// Copyright (c) 2012 GitHub. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSView+RBLViewControllerAdditions.h"
|
||||
#import "RBLViewController.h"
|
||||
#import "NSObject+RBObjectSizzlingAdditions.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
void *kRBLViewControllerKey = &kRBLViewControllerKey;
|
||||
|
||||
@implementation NSView (NSView_RBLViewControllerAdditions)
|
||||
|
||||
#pragma mark - ViewController
|
||||
|
||||
- (id)rbl_viewController {
|
||||
return objc_getAssociatedObject(self, kRBLViewControllerKey);
|
||||
}
|
||||
|
||||
- (void)setRbl_viewController:(id)newViewController {
|
||||
[NSView loadSupportForRBLViewControllers];
|
||||
|
||||
if (self.rbl_viewController) {
|
||||
NSResponder *controllerNextResponder = [self.rbl_viewController nextResponder];
|
||||
[self custom_setNextResponder:controllerNextResponder];
|
||||
[self.rbl_viewController setNextResponder:nil];
|
||||
}
|
||||
|
||||
objc_setAssociatedObject(self, kRBLViewControllerKey, newViewController, OBJC_ASSOCIATION_ASSIGN);
|
||||
|
||||
if (newViewController) {
|
||||
NSResponder *ownResponder = [self nextResponder];
|
||||
[self custom_setNextResponder:self.rbl_viewController];
|
||||
[self.rbl_viewController setNextResponder:ownResponder];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - View Controller Methods
|
||||
|
||||
+ (void)loadSupportForRBLViewControllers {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
//swizzle swizzle...
|
||||
[self rbl_swapMethod:@selector(viewWillMoveToSuperview:) with:@selector(custom_viewWillMoveToSuperview:)];
|
||||
[self rbl_swapMethod:@selector(viewDidMoveToSuperview) with:@selector(custom_viewDidMoveToSuperview)];
|
||||
|
||||
[self rbl_swapMethod:@selector(viewWillMoveToWindow:) with:@selector(custom_viewWillMoveToWindow:)];
|
||||
[self rbl_swapMethod:@selector(viewDidMoveToWindow) with:@selector(custom_viewDidMoveToWindow)];
|
||||
|
||||
[self rbl_swapMethod:@selector(setNextResponder:) with:@selector(custom_setNextResponder:)];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)custom_viewWillMoveToSuperview:(NSView *)newSuperview {
|
||||
[self custom_viewWillMoveToSuperview:newSuperview];
|
||||
|
||||
if ([self.rbl_viewController isKindOfClass:[RBLViewController class]]) {
|
||||
if (newSuperview == nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillBeRemovedFromSuperview];
|
||||
|
||||
if ((self.superview != nil) && (self.window != nil)) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillDisappear];
|
||||
}
|
||||
} else {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillMoveToSuperview:newSuperview];
|
||||
|
||||
if (self.window != nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillAppear];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)custom_viewDidMoveToSuperview {
|
||||
[self custom_viewDidMoveToSuperview];
|
||||
|
||||
if ([self.rbl_viewController isKindOfClass:[RBLViewController class]]) {
|
||||
if (self.superview == nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWasRemovedFromSuperview];
|
||||
|
||||
if (self.window == nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewDidDisappear];
|
||||
}
|
||||
} else {
|
||||
[(RBLViewController *)self.rbl_viewController viewDidMoveToSuperview];
|
||||
|
||||
if (self.window != nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewDidAppear];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)custom_viewWillMoveToWindow:(NSWindow *)newWindow {
|
||||
[self custom_viewWillMoveToWindow:newWindow];
|
||||
|
||||
if ([self.rbl_viewController isKindOfClass:[RBLViewController class]]) {
|
||||
if (newWindow == nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillBeRemovedFromWindow];
|
||||
|
||||
if ((self.superview != nil) && (self.window != nil)) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillDisappear];
|
||||
}
|
||||
} else {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillMoveToWindow:newWindow];
|
||||
|
||||
if (self.superview != nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWillAppear];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)custom_viewDidMoveToWindow {
|
||||
[self custom_viewDidMoveToWindow];
|
||||
|
||||
if ([self.rbl_viewController isKindOfClass:[RBLViewController class]]) {
|
||||
if (self.window == nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewWasRemovedFromWindow];
|
||||
|
||||
if (self.superview == nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewDidDisappear];
|
||||
}
|
||||
} else {
|
||||
[(RBLViewController *)self.rbl_viewController viewDidMoveToWindow];
|
||||
|
||||
if (self.superview != nil) {
|
||||
[(RBLViewController *)self.rbl_viewController viewDidAppear];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)custom_setNextResponder:(NSResponder *)newNextResponder {
|
||||
if (self.rbl_viewController != nil) {
|
||||
[self.rbl_viewController setNextResponder:newNextResponder];
|
||||
return;
|
||||
}
|
||||
|
||||
[self custom_setNextResponder:newNextResponder];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,35 +0,0 @@
|
|||
//
|
||||
// RBLViewController.h
|
||||
// Rebel
|
||||
//
|
||||
// Created by Colin Wheeler on 10/29/12.
|
||||
// Copyright (c) 2012 GitHub. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface RBLViewController : NSViewController
|
||||
|
||||
+ (instancetype)viewController;
|
||||
|
||||
- (void)viewDidLoad;
|
||||
|
||||
// Called when the view has a superview and window. This does not necessarily mean the view is visible.
|
||||
- (void)viewWillAppear;
|
||||
- (void)viewDidAppear;
|
||||
|
||||
// Called when the view no longer has a superview or no longer has a window.
|
||||
- (void)viewWillDisappear;
|
||||
- (void)viewDidDisappear;
|
||||
|
||||
- (void)viewWillMoveToSuperview:(NSView *)newSuperview;
|
||||
- (void)viewDidMoveToSuperview;
|
||||
- (void)viewWillBeRemovedFromSuperview;
|
||||
- (void)viewWasRemovedFromSuperview;
|
||||
|
||||
- (void)viewWillMoveToWindow:(NSWindow *)newWindow;
|
||||
- (void)viewDidMoveToWindow;
|
||||
- (void)viewWillBeRemovedFromWindow;
|
||||
- (void)viewWasRemovedFromWindow;
|
||||
|
||||
@end
|
|
@ -1,85 +0,0 @@
|
|||
//
|
||||
// RBLViewController.m
|
||||
// Rebel
|
||||
//
|
||||
// Created by Colin Wheeler on 10/29/12.
|
||||
// Copyright (c) 2012 GitHub. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RBLViewController.h"
|
||||
#import "NSView+RBLViewControllerAdditions.h"
|
||||
|
||||
@interface RBLViewController ()
|
||||
|
||||
@property (nonatomic, strong) NSView *currentView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RBLViewController
|
||||
|
||||
+ (instancetype)viewController {
|
||||
return [[self alloc] initWithNibName:NSStringFromClass([self class]) bundle:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (_currentView.rbl_viewController == self) {
|
||||
_currentView.rbl_viewController = nil;
|
||||
}
|
||||
_currentView = nil;
|
||||
}
|
||||
|
||||
- (void)loadView {
|
||||
[super loadView];
|
||||
[self viewDidLoad];
|
||||
}
|
||||
|
||||
- (void)setView:(NSView *)view {
|
||||
super.view = view;
|
||||
self.view.rbl_viewController = self;
|
||||
|
||||
if (_currentView.rbl_viewController == self) {
|
||||
_currentView.rbl_viewController = nil;
|
||||
}
|
||||
_currentView = view;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
}
|
||||
|
||||
- (void)viewWillAppear {
|
||||
}
|
||||
|
||||
- (void)viewDidAppear {
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear {
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear {
|
||||
}
|
||||
|
||||
- (void)viewWillMoveToSuperview:(NSView *)newSuperview {
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToSuperview {
|
||||
}
|
||||
|
||||
- (void)viewWillBeRemovedFromSuperview {
|
||||
}
|
||||
|
||||
- (void)viewWasRemovedFromSuperview {
|
||||
}
|
||||
|
||||
- (void)viewWillMoveToWindow:(NSWindow *)newWindow {
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToWindow {
|
||||
}
|
||||
|
||||
- (void)viewWillBeRemovedFromWindow {
|
||||
}
|
||||
|
||||
- (void)viewWasRemovedFromWindow {
|
||||
}
|
||||
|
||||
@end
|
Загрузка…
Ссылка в новой задаче