This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <dict> | |
| <key>Title</key> | |
| <string>ClearDataGroup</string> | |
| <key>Type</key> | |
| <string>PSGroupSpecifier</string> | |
| </dict> | |
| <dict> | |
| <key>DefaultValue</key> | |
| <false/> | |
| <key>Key</key> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | let resetKey = "com.detroitlabs.shopfast.ResetPriorities" | |
| func checkForResetTrigger() { | |
| let userDefaults = NSUserDefaults.standardUserDefaults() | |
| let shouldReset = userDefaults.boolForKey(resetKey) | |
| if shouldReset { | |
| self.products = [] | |
| userDefaults.removeObjectForKey(self.productsKey) | |
| userDefaults.setBool(false, forKey: resetKey) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | func applicationWillEnterForeground(application: UIApplication) { | |
| PrioritiesManager.sharedInstance.checkForResetTrigger() | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | func applicationWillEnterForeground(application: UIApplication) { | |
| PrioritiesManager.sharedInstance.checkForResetTrigger() | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class ShoppingListManager : ProductManager { | |
| static let sharedInstance = ShoppingListManager() | |
| override init() { | |
| super.init() | |
| self.productsKey = "com.detroitlabs.shopfast.products" | |
| self.loadProductsFromDefaults() | |
| } | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class FavoritesManager : ProductManager { | |
| static let sharedInstance = FavoritesManager() | |
| override init() { | |
| super.init() | |
| self.productsKey = "com.detroitlabs.shopfast.favorites" | |
| self.loadProductsFromDefaults() | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
| if let cell = tableView.dequeueReusableCellWithIdentifier("Product Cell") as? ProductCell { | |
| let product = self.shoppingListManager.productAtIndex(indexPath.row) | |
| if product.purchased { | |
| let attr = [NSStrikethroughStyleAttributeName: NSUnderlineStyle.StyleSingle.rawValue] | |
| let attrString = NSAttributedString(string: product.name, attributes: attr) | |
| cell.productNameLabel.attributedText = attrString | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | func leftButtonsForProduct(product: Product) -> [UIButton] { | |
| let buttons : NSMutableArray = NSMutableArray() | |
| if self.favoritesManager.isProductFavorited(product) { | |
| buttons.sw_addUtilityButtonWithColor(UIColor(red: 224/255, green: 224/255, blue: 103/255, alpha: 1), title: "Faved") | |
| } | |
| else { | |
| buttons.sw_addUtilityButtonWithBackgroundColor(UIColor.whiteColor(), title: "Fav", titleColor: UIColor.blackColor()) | |
| } | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | func isProductFavorited(product: Product) -> Bool { | |
| if let _ = self.findProductByName(product.name) { | |
| return true | |
| } | |
| else { | |
| return false | |
| } | |
| } | |
| func findProductByName(name: String) -> Product? { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | func swipeableTableViewCell(cell: SWTableViewCell!, didTriggerLeftUtilityButtonWithIndex index: Int) { | |
| switch index { | |
| case LeftUtilityButtons.AddToList.rawValue: | |
| if let indexPath = self.favoritesTableView.indexPathForCell(cell) as NSIndexPath! { | |
| let fav = self.favoritesManager.productAtIndex(indexPath.row) | |
| self.shoppingListManager.addProduct(fav) | |
| } | |
| default: | |
| break | |
| } |