I completed the second code challenge on the Udemy iOS 11 Swift - Complete iOS App development Bootcamp video tutorial course and like to share the result with you.
The App starts with a short story and 2 buttons that give the user two choices on how to continue. The user decision will influence the rest of the story. This challenge is using a quit simple story but I think with a bit of time this app could be build out to a nice full fledged story App.
Story structure from the Udemy course
The essential part in this app is to navigate through the storyline based on the choices the user makes. In order to know which button has been pressed, a "Tag" was assigned to the top (Tag number 1) and bottom (tag number 2) button. In addition to the button pressed, I had to add a story index variable that got updated once I reached a new part of the story. With this identifier in place I created an if /if else block that went to the various options. The important part was to add an AND condition to the IF blocks in order to navigate to the next story based on the choice the user made.
This challenge was a lot a fun and I learned how to display dynamic text on buttons as well as increase my knowledge with conditional statements.
I can't wait to get to the next challenge, once complete will share with you again.
All the best.