Fix visibility assert on iOS 7

It appears that didMoveToViewController: can be called with nil,
yet self.parentViewController will *not* be nil. This can result
in calling parent view controller's visibility depth. Instead of
asserting, these methods should return NSNotFound which also happens
to be a really large number, effectively infinite depth.
This commit is contained in:
Garrett Moon
2016-07-06 13:35:40 -07:00
parent c62a4d3e79
commit 8081123cb2
2 changed files with 10 additions and 1 deletions

View File

@@ -40,7 +40,10 @@ ASVisibilityDepthImplementation;
- (NSInteger)visibilityDepthOfChildViewController:(UIViewController *)childViewController
{
NSUInteger viewControllerIndex = [self.viewControllers indexOfObject:childViewController];
NSAssert(viewControllerIndex != NSNotFound, @"childViewController is not in the navigation stack.");
if (viewControllerIndex == NSNotFound) {
//If childViewController is not actually a child, return NSNotFound which is also a really large number.
return NSNotFound;
}
if (viewControllerIndex == self.viewControllers.count - 1) {
//view controller is at the top, just return our own visibility depth.