From 2a8f7294d1e75c5ffce3224b278bc11e21b0282e Mon Sep 17 00:00:00 2001 From: Rhys Walden Date: Thu, 30 Oct 2014 09:07:09 +1300 Subject: [PATCH] changed internal cache key from NSIndexPath -> NSString - this is to fix a very small intermittent bug where the cached VC is not found (when it is in the cache) --- .../SASlideMenu/SASlideMenuRootViewController.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SASlideMenu/SASlideMenu/SASlideMenuRootViewController.m b/SASlideMenu/SASlideMenu/SASlideMenuRootViewController.m index 654d108..6639433 100644 --- a/SASlideMenu/SASlideMenu/SASlideMenuRootViewController.m +++ b/SASlideMenu/SASlideMenu/SASlideMenuRootViewController.m @@ -13,6 +13,8 @@ #define kMenuTableSize 280 #define kSwipeMinDetectionSpeed 0.1f +NSString * const cachingKeyFormat = @"%li,%li"; + typedef enum { SASlideMenuStateInitial, @@ -407,7 +409,12 @@ -(void) panItem:(UIPanGestureRecognizer*)gesture{ } -(UINavigationController*) controllerForIndexPath:(NSIndexPath*) indexPath{ - return [controllers objectForKey:indexPath]; + return [controllers objectForKey:[self getNSIndexPathKey:indexPath]]; +} + +-(NSString*)getNSIndexPathKey:(NSIndexPath*)indexPath +{ + return [NSString stringWithFormat:cachingKeyFormat, indexPath.section, indexPath.row]; } -(void) switchToContentViewController:(UINavigationController*) content completion:(void (^)(void))completion{ @@ -495,7 +502,7 @@ -(void) addContentViewController:(UIViewController*) content withIndexPath:(NSIn disableContentViewControllerCaching = [self.leftMenu.slideMenuDataSource disableContentViewControllerCachingForIndexPath:indexPath]; } if (!disableContentViewControllerCaching) { - [controllers setObject:content forKey:indexPath]; + [controllers setObject:content forKey:[self getNSIndexPathKey:indexPath]]; } } }