Skip to content
Browse files

Added class-check in setViewControllers (thanks to Jeffrey903)

  • Loading branch information...
1 parent c0be04c commit 35404e31ef5fe972d3acc4fab447a2a995af3e18 @mattgemmell committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 Classes/MGSplitViewController.m
4 Classes/MGSplitViewController.m
@@ -814,7 +814,9 @@ - (void)setViewControllers:(NSArray *)controllers
if (controllers != _viewControllers) {
for (UIViewController *controller in _viewControllers) {
- [controller.view removeFromSuperview];
+ if ([controller isKindOfClass:[UIViewController class]]) {
+ [controller.view removeFromSuperview];
+ }
[_viewControllers release];
_viewControllers = [[NSMutableArray alloc] initWithCapacity:2];

1 comment on commit 35404e3


It seems the issue is whether or not the supposed UIViewController has a view. Instead of testing its class, wouldn't it be simultaneously more direct and less restrictive to test whether [controller respondsToSelector:@selector(view)]?

Please sign in to comment.
Something went wrong with that request. Please try again.