Permalink
Browse files

Use MTCollectionOperators

  • Loading branch information...
1 parent 6184a5f commit 16078050654cd41e10422789782f667d60d0137b @mtrudel committed Mar 19, 2013
Showing with 6 additions and 8 deletions.
  1. +5 −8 Classes/iOS/MTStackableNavigationController.m
  2. +1 −0 MTStackableNavigationController.podspec
@@ -10,6 +10,7 @@
#import "MTStackableNavigationController.h"
#import "MTStackableNavigationItem_Protected.h"
#import "UIViewController+MTStackableNavigationController_Protected.h"
+#import "NSArray+MTCollectionOperators.h"
#define kAnimationDuration 0.3
#define kCoveredControllerWidthDivisor 2
@@ -111,8 +112,7 @@ - (UINavigationController *)ancestorViewControllerTo:(UIViewController *)viewCon
}
- (NSArray *)expectedVisibleViewControllersWithPendingRemovals:(NSArray *)pendingRemovals {
- NSMutableArray *viewControllers = [self.childViewControllers mutableCopy];
- [viewControllers removeObjectsInArray:pendingRemovals];
+ NSArray *viewControllers = [self.childViewControllers subtractValuesIn:pendingRemovals];
if ([[[self ancestorViewControllerTo:[viewControllers lastObject]] stackableNavigationItem] leftPeek] != 0) {
return @[[self ancestorViewControllerTo:[viewControllers lastObject]], [viewControllers lastObject]];
} else {
@@ -150,12 +150,9 @@ - (void)updateViewControllerHierarchyWithPendingRemovals:(NSArray *)pendingRemov
if (self.isViewLoaded) {
NSArray *expectedHierarchy = [self expectedVisibleViewControllersWithPendingRemovals:pendingRemovals];
NSArray *currentHierarchy = [self currentlyVisibleViewControllers];
- NSMutableArray *toRemove = [currentHierarchy mutableCopy];
- [toRemove removeObjectsInArray:expectedHierarchy];
- NSMutableArray *toUpdate = [currentHierarchy mutableCopy];
- [toUpdate removeObjectsInArray:toRemove];
- NSMutableArray *toInsert = [expectedHierarchy mutableCopy];
- [toInsert removeObjectsInArray:currentHierarchy];
+ NSArray *toRemove = [currentHierarchy subtractValuesIn:expectedHierarchy];
+ NSArray *toUpdate = [currentHierarchy subtractValuesIn:toRemove];
+ NSArray *toInsert = [expectedHierarchy subtractValuesIn:currentHierarchy];
// Load the new views (induce loadView if needed)
for (UIViewController *viewController in toInsert) {
@@ -18,4 +18,5 @@ Pod::Spec.new do |s|
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
s.framework = 'QuartzCore'
s.requires_arc = true
+ s.dependency 'MTCollectionOperators', '~> 0'
end

0 comments on commit 1607805

Please sign in to comment.