April 2020
Beginner
316 pages
8h 20m
English
First, we need to add a couple of small functions to our RecipeModel() struct. Head on over to RecipeModel.swift and add in the following functions. I suggest you grab them from the example code rather than type them out in full as we only really need to know what they do rather than how they do it:
func toJson() -> String { // Get function from Code Sample}static func createFrom(json: String) -> RecipeModel { // Get function from Code Sample}
The toJson function will simply convert RecipeModel() into a JSON string that we can add to our WCSession.sendMessage() call.
The createFrom static function will convert our JSON string back into RecipeModel() on the watchOS side.
Next, head on over to AddRecipeView.swift and ...
Read now
Unlock full access