Created
November 24, 2015 16:19
-
-
Save ctrevarthen/8cc712ac4a004c4fa893 to your computer and use it in GitHub Desktop.
ShopQuick - Rule 1
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 lastProductPurchased : Product? | |
override init() { | |
super.init() | |
self.productsKey = "com.detroitlabs.shopfast.priorities" | |
self.loadProductsFromDefaults() | |
} | |
func addProduct(product: Product) { | |
let newProduct = Product(name: product.name, qty: 0) | |
if let _ = lastProductPurchased, | |
let index : Int = self.findIndexForProductName(lastProductPurchased!.name) { | |
self.insertProduct(newProduct, atIndex: index + 1) // Rule #1 | |
} | |
lastProductPurchased = product | |
self.saveProductsToDefaults() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment