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
| 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
| <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
| class PrioritiesManager : ProductManager { | |
| static let sharedInstance = PrioritiesManager() | |
| var productsInThisTrip : [Product]? | |
| func addProduct(product: Product) { | |
| let newProduct = Product(name: product.name, qty: 0) | |
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 addProduct(product: Product) { | |
| let newProduct = Product(name: product.name, qty: 0) | |
| // if the product exists | |
| if self.doesProductExist(newProduct.name) { | |
| // if there is a last item purchased | |
| if let lastProduct = self.lastProductPurchased { | |
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 addProduct(product: Product) { | |
| let newProduct = Product(name: product.name, qty: 0) | |
| // if the product exists | |
| if self.doesProductExist(newProduct.name) { | |
| // if there is a last item purchased | |
| if let lastProduct = self.lastProductPurchased { | |
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() | |
| let prioritiesManager = PrioritiesManager.sharedInstance | |
| func markPurchasedAtIndex(index: Int) { | |
| let product = self.products[index] | |
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 addProduct(product: Product) { | |
| let newProduct = Product(name: product.name, qty: 0) | |
| // if the product exists | |
| if self.doesProductExist(newProduct.name) { | |
| // if there is a last item purchased | |
| if let lastProduct = self.lastProductPurchased { |
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 addProduct(product: Product) { | |
| let newProduct = Product(name: product.name, qty: 0) | |
| if let _ = lastProductPurchased, | |
| let index : Int = self.findIndexForProductName(lastProductPurchased!.name) { | |
| // if the new product already exists | |
| if let _ = self.findProductByName(newProduct.name) { | |
| // do nothing -- Rule #2 |