Before we can save the reviews, we need to get all of the data. Getting text from a text field and text view is pretty simple, so we will do that. However, we need a way to let users rate a restaurant by giving it a star rating. The ratings range from 0 to 5 with increments of 0.5. We will use a Picker View to display the stars. Let's get started with this:
Right-click the
Model
folder in theReview
folder and select New File.Inside of the Choose a template for your new file screen, select iOS at the top and then select Swift File. Then hit Next.
Name this file
Rating
and hit Create.
Under the import
statement, add the following:
enum Rating { case zero case half case one case oneHalf case two case twoHalf case three case threeHalf case four case fourHalf case five }
Now that we have a case for each type of rating, we want a way to be able to have a value that we can use for a rating. Add the following variable inside of the enum...