Repository navigation
RBLViewControllerAddition replaces wrong method. - #87
Conversation
What problems does this cause in practice?
Semantically, this makes sense, but subclass overrides are not required to invoke |
|
For example, viewWillMoveToWindow will only get swapped once. So depending on how you're code is loaded it replaces the wrong method. When you use this view with RBLViewController viewWillMoveToWindow will get replaced as expected. However on you're second view you create... When you use this view with RBLViewController, not all the ViewController calls will be called. This is because the swap method only runs once and it ran and replaced MyInitialView's viewWillMoveToWindow. If you subclass MyInitialView, it will work as expected. I'm not quite what you mean by RBLViewController implementation would get skipped. From what I understand RBLViewController kick starts everything. |
Ah, indeed. Sorry, I misunderstood your original problem description. In that case, the proper fix would be making sure that any used view classes receive a custom implementation of
The documentation for Developers often avoid calling @implementation CustomView : NSView
- (void)viewDidMoveToWindow {
NSLog(@"%s", __func__);
}
@endIf we set up a couple view controllers: NSView *standardView = [[NSView alloc] initWithFrame:NSZeroRect];
RBLViewController *standardVC = [RBLViewController viewController];
standardView.rbl_viewController = standardVC;
CustomView *customView = [[CustomView alloc] initWithFrame:NSZeroRect];
RBLViewController *customVC = [RBLViewController viewController];
customView.rbl_viewController = customVC;… then Anyways, although this is a real problem, I think your fix is better than what we have currently, so I'll merge it in. Thanks! ✨ |
RBLViewControllerAddition replaces wrong method.
If the first view you use happens to be overloading any of the method, for example viewWillMoveToWindow, the swap function will swap out the overloaded class with the custom_ version.
The swap should replace the base implementation that is provided by the NSView. This patch will force the NSView's method to be replaced instead of the overloaded method.