subject

Imagine a screen where a user inputs a meal that they've eaten. If the user taps a "save" button without adding any food, you might want to prompt the user that they haven't actually added anything. Using the Food struct and the text fields provided below, create a function called logFood that takes no parameters and returns an optional Food object. Inside the body of the function, use a guard statement to unwrap the text property of food TextField and calories TextField. In addition to unwrapping calories TextField, you'll need to create and unwrap a new variable that initializes an Int from the text in caloriesTextField. If any of this fails, return nil. After the guard statement, create and return a Food object.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, hailee232
What is a society that has moved to the internet rather than relying on physical media called
Answers: 2
image
Computers and Technology, 22.06.2019 17:30, jonquil201
Where would you click to edit the chart data?
Answers: 1
image
Computers and Technology, 23.06.2019 22:50, christingle2004
What is an rss reader used for? for creating a user account on a social new site
Answers: 2
image
Computers and Technology, 24.06.2019 00:40, ndurairajownkpq
What social factors affect your health
Answers: 3
You know the right answer?
Imagine a screen where a user inputs a meal that they've eaten. If the user taps a "save" button wit...

Questions in other subjects: