Skip to content

Commit

Permalink
Merge pull request cocoabits#34 from swt2c/fix_double_viewWillAppear
Browse files Browse the repository at this point in the history
Avoid calling viewWillAppear twice on OSX 10.10
  • Loading branch information
Vadim Shpakovski committed Dec 24, 2014
2 parents 2102ca2 + 20c8986 commit 966530c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions MASPreferencesWindowController.m
Expand Up @@ -303,8 +303,12 @@ - (void)setSelectedViewController:(NSViewController <MASPreferencesViewControlle
#else
_selectedViewController = [controller retain];
#endif
if ([controller respondsToSelector:@selector(viewWillAppear)])
[controller viewWillAppear];
// In OSX 10.10, setContentView below calls viewWillAppear. We still want to call viewWillAppear on < 10.10,
// so the check below avoids calling viewWillAppear twice on 10.10.
// See https://github.com/shpakovski/MASPreferences/issues/32 for more info.
if (![NSViewController instancesRespondToSelector:@selector(viewWillAppear)])
if ([controller respondsToSelector:@selector(viewWillAppear)])
[controller viewWillAppear];

[self.window setContentView:controllerView];
[self.window recalculateKeyViewLoop];
Expand Down

0 comments on commit 966530c

Please sign in to comment.