Skip to content

Instantly share code, notes, and snippets.

@ctrevarthen
Last active November 19, 2015 03:37
Show Gist options
  • Save ctrevarthen/394b1f44cb7eb26f575c to your computer and use it in GitHub Desktop.
Save ctrevarthen/394b1f44cb7eb26f575c to your computer and use it in GitHub Desktop.
ShopQuick - Favorites Manager - Is Favorited?
func isProductFavorited(product: Product) -> Bool {
if let _ = self.findProductByName(product.name) {
return true
}
else {
return false
}
}
func findProductByName(name: String) -> Product? {
let results = self.products.filter { (found: Product) -> Bool in
if found.name == name {
return true
}
return false
}
return results.first
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment