YouTube Tutorial: Code With Chris
How to Make an App for Beginners (Xcode 9, Swift 4)
Lesson 3
seen from Sweden
seen from China

seen from Vietnam

seen from Türkiye
seen from China
seen from United Kingdom
seen from Australia

seen from United States

seen from United States
seen from United States

seen from Hong Kong SAR China

seen from Portugal
seen from Malaysia
seen from United Kingdom
seen from Saudi Arabia
seen from India
seen from China

seen from Italy

seen from United States
seen from Malaysia
YouTube Tutorial: Code With Chris
How to Make an App for Beginners (Xcode 9, Swift 4)
Lesson 3
Version 0.18
After all the ‘fun’ i had with segues last time, I didn't actually get around to creating a final ‘game over you scored X’ screen.
First thing I did was create this page. Its simple enough in terms of content. we have the logo at the top, the players final score as a text field, then a back button to return the player to the main menu. I also created the required segues from the game to this final page, then from the final page back to the menu. This is my finished storyboard:
Next, I needed to go into the game ViewController and edit the code slightly. Essentially, I need to change the last UIAlert message box that appears. All of the information displayed here I want to transfer to the final screen.
In the GameViewController swift file, I went to the GameOver section. Instead of calling the GameOver function, I replaced it with this code:
performSegue(withIdentifier: "gametofinal", sender: self)
In order to go straight to the final screen.
On the final screen view controller, I edited the instance of the textbox so that it would display all of the key information. Then needed to pass the variable score from the Game ViewController to the Final ViewController.
To do this, in the Final ViewController I created a vairable called ‘StringToSegue’ and set it as a String variable. Then in the Game ViewController, I added the following code.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let FinalViewController = segue.destination as! FinalViewController FinalViewController.StringToSegue = String(score) }
This code essentially links the two ViewControllers together so that they can pass data. I then set the variable FinalViewController as the casted String of variable Score.
The final result allows me to get the final score passed across and displayed at the end of the game on the final screen.
“In Xcode 8, place the cursor above a method or function & press "⌥ + ⌘ + /" to auto-generate a doc comment. #protip https://t.co/t8imJ2bayu”
After reinstalling Xcode 4.3, I lost the gcc-4.2. Installing the command line tools component did not fix it. May need to run "brew install <url to gcc formula>"?
Xcode和git相處好融洽喲~QQ
簡直是水乳交融了