Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Rebel/RBLViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

@interface RBLViewController ()

@property (nonatomic, strong) NSView *currentView;

@end

@implementation RBLViewController
Expand All @@ -20,6 +22,13 @@ +(id)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];
Expand All @@ -30,6 +39,11 @@ -(void)setView:(NSView *)view
{
super.view = view;
self.view.rbl_viewController = self;

if (_currentView.rbl_viewController == self) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling self.view before super.view = view would cause an infinit loop.

self.view accessor instantiates loadView or the nib and ends up calling setView.

Hmm, very true, but this seems hacky. I don't think I have a better solution right now, though.

_currentView.rbl_viewController = nil;
}
_currentView = view;
}

- (void)viewDidLoad
Expand Down