Permalink
Browse files

Empty cart on logout

  • Loading branch information...
1 parent 898f3d7 commit 38fceb3ad10bd03103e42d926e8bab58cfce07c0 @sthompson committed Apr 16, 2012
@@ -21,6 +21,7 @@
@property(weak, nonatomic) IBOutlet UIButton *registerButton;
@property (nonatomic, retain) IBOutlet UIScrollView *scroller;
+@property (strong, nonatomic) NSString *userKey;
@property (strong, nonatomic) RestaurantViewController *restaurantViewController;
//@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@@ -14,7 +14,7 @@
@implementation LoginViewController
-@synthesize username,password,loginButton,registerButton,seatNumber,scroller;
+@synthesize username,password,loginButton,registerButton,seatNumber,scroller,userKey;
@synthesize restaurantViewController;
//@synthesize fetchedResultsController = __fetchedResultsController;
@synthesize managedObjectContext = __managedObjectContext;
@@ -148,6 +148,7 @@ -(void)selectedStadium:(NSString *)stadiumName fromSender:(id)sender
stadiumName];
self.restaurantViewController.cart = [[Cart alloc]init];
self.restaurantViewController.managedObjectContext =self.managedObjectContext;
+ self.restaurantViewController.userKey = self.userKey;
[self.navigationController pushViewController:self.restaurantViewController animated:YES];
}
@@ -18,6 +18,7 @@
@property (strong, nonatomic) Cart *cart;
@property (strong, nonatomic) NSArray *restaurants;
@property (strong, nonatomic) NSString *stadiumName;
+@property (strong, nonatomic) NSString *userKey;
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@@ -17,7 +17,7 @@
@implementation RestaurantViewController
@synthesize menuViewController = _menuViewController;
-@synthesize restaurants,stadiumName,cart;
+@synthesize restaurants,stadiumName,cart,userKey;
@synthesize fetchedResultsController = __fetchedResultsController;
@synthesize managedObjectContext = __managedObjectContext;
@synthesize tableViewCell;
@@ -67,9 +67,11 @@ - (void)viewDidAppear:(BOOL)animated
[super viewDidAppear:animated];
}
-- (void)viewWillDisappear:(BOOL)animated
-{
- [super viewWillDisappear:animated];
+-(void) viewWillDisappear:(BOOL)animated {
+ if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
+ [Model emptyCart:self.userKey];
+ }
+ [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated

0 comments on commit 38fceb3

Please sign in to comment.