Scott iOS journal

I have gone thru the Module 3 matching card game. Have gone thru the module several time to understand it.

Copied and pasted Chris code since my code is not working properly. Could not get the autofilling fields listed in the video tutorials. I think the Xcode version I have and what is on the video are slightly different so the options for the auto fill-in fields are different.

Using breakpoints to understand the flow of the program from startup to end. Also using print statements to find out what the array has stored.

Trying to modify the alert button and the timer at the end of module 3. Game logic for winning works but timer still runs in the background. I would like the timer to stop after the user wins the matching game. Alert button I would like to modify so the user can try the game again.

Changed the amount of time that I have to finish the game. Changed the simulator to iPad. Larger screen less scrolling when I am testing.

Running iMac mini and Xcode version 11.6 under Catalina. Considering upgrading to Sur and Xcode but worried it will make the tutorials difficult to follow using a different version of software.

  • Jan 12 2021

Scott,

       I have issues with autocoding only with the terminal. All kinds of unpredictable issues.

Fixed the timer. It was not stopping at the end of the game. Put the timer?.invalidate in the wrong branch of the if statement.

Ran it again and tested fine.

Going to have to watch how I spell variables and where the curly brackets are placed. Spent two hours trying to track down a bug only to figure out that I capitalized the variable when I declared it.

Also going to watch if the color changes and the auto populate(?) when coding. I should realize by now if the color does not change I have made a syntax or variable declaration incorrectly. Going to have to start writing it down on paper to keep track.

Thinking out loud here.

I think the variable scope is within the file you declare it. If I declare it in the ViewController.swift the variable is only available in the same swift file. If I use the variable inside the same swift file it is still available for me to use.

Still working on understanding optional chaining. I have a rough idea but not enough to stray from the original code to test it.

Still working on understanding functions and how they return values. I understand the theory but cannot seem to apply it properly.

In the module Chris adds code to filter out the duplicate pairs. I have yet to see a duplicate. Used my own code typed from the videos. Ran the app simulator about 15 times without any duplication.

Going to run thru the module 3 again trying for the most part to do it from memory. Consulting with the videos when I get stuck.

In the checkForGameEnd method, write the following in the if statement where hasWon is true.

timer?.invalidate()

showAlert(title: “Congratulations!”, message: “You have won the game!”)