Last active
July 9, 2018 11:40
-
-
Save PattoMotto/3a1cfd2538eed6c6f1a82978a555aecf to your computer and use it in GitHub Desktop.
Model and Manager class, full project https://github.com/neungnarakjung/CookBook-Siri-Shortcuts-Example
This file contains 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
struct Recipe: Codable { | |
let identifier: String | |
let name: String | |
let instruction: [String] | |
} | |
protocol CookBookDataManager { | |
func getRecipe(_ identifier: String) -> Recipe? | |
} | |
final class CookBookDataManagerImpl: CookBookDataManager { | |
private lazy var recipes: [Recipe] = { | |
return [ | |
Recipe( | |
identifier: "foo", | |
name: "Foo Bar", | |
instruction: ["Foo", "Bar"] | |
) | |
] | |
}() | |
func getRecipe(_ identifier: String) -> Recipe? { | |
return recipes.filter{ $0.identifier == identifier }.first | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment