Angela Yu Xcode 12 Course - Part 6 (lectures 55 to 73)
Here we are! Last time was such a short entry and this one will be fairly brief too! So I've got a bit of time now and most likely no more until tomorrow. Am enjoying Angela's course immensely - so may bits seem fresh and new, so well worth the £10. Every time she brings out a new Swift course I have to get it! Anyway, diving in...
Start Time - 12:32
Magic 8 Ball Project
Right, making Magic 8 Ball App. Even though I made this once around 6 months ago, am going to try it without any tips! Let's go!
Right app icons...yes it worked! Had to check the Dicee way from a few lessons ago. Basically, I need to empty that folder including the JSON file. Then replace it with the whole folder of new app icons. Cool!
Right so the IMAGE files need to be actually clicked and dragged into the image folder ON XCODE!!
Cool, using Ray's tip, I'm going to do my to-do list rather than follow Angela's steps - much more of a challenge.
This is what I'm trying to create. Of course it doesn't have to be EXACTLY like this -

So on the to-do list
View
A background colour
A 'question' label
An eight ball image
A text box in the middle of the 8 ball
An ask button/function
Controller
Function for ask button
Array for texts for 8 ball
Randomisation for choosing text in 8 ball
That's it I think! Let's get the main view set up now...

OK View done! With all constraints too.
Something else though - no textbox for 8 ball messages - instead, a series of images. So need to do the same as dicee for the UIImage views...
Woohoo! It works!
That will do for today! Managed to very successfully complete Angela's challenge without any tips. Very rewarding! The practice bit was fine, covering values, comments, functions...all a useful recap.
Start Time - 12:32
Magic 8 Ball Project
Right, making Magic 8 Ball App. Even though I made this once around 6 months ago, am going to try it without any tips! Let's go!
Right app icons...yes it worked! Had to check the Dicee way from a few lessons ago. Basically, I need to empty that folder including the JSON file. Then replace it with the whole folder of new app icons. Cool!
Right so the IMAGE files need to be actually clicked and dragged into the image folder ON XCODE!!
Cool, using Ray's tip, I'm going to do my to-do list rather than follow Angela's steps - much more of a challenge.
This is what I'm trying to create. Of course it doesn't have to be EXACTLY like this -

So on the to-do list
View
A background colour
A 'question' label
An eight ball image
A text box in the middle of the 8 ball
An ask button/function
Controller
Function for ask button
Array for texts for 8 ball
Randomisation for choosing text in 8 ball
That's it I think! Let's get the main view set up now...

OK View done! With all constraints too.
Something else though - no textbox for 8 ball messages - instead, a series of images. So need to do the same as dicee for the UIImage views...
Woohoo! It works!
import UIKit
class ViewController: UIViewController {
var randomNumber = 0
let eightBallArray = ["ball1", "ball2", "ball3", "ball4", "ball5"]
@IBOutlet weak var eightBallDisplay: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func askButton(_ sender: UIButton) {
randomNumber = Int.random(in: 0...4)
eightBallDisplay.image = UIImage(named: eightBallArray[randomNumber])
}
}
Something I could do is to have a separate function to update the eightBall, then have that on the viewDidLoad, so that it does NOT always start with 'Ask Again Later'...
Yes that's even better - same principle as Dicee app!
import UIKit
class ViewController: UIViewController {
var randomNumber = 0
let eightBallArray = ["ball1", "ball2", "ball3", "ball4", "ball5"]
@IBOutlet weak var eightBallDisplay: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
updateEightBall()
}
@IBAction func askButton(_ sender: UIButton) {
updateEightBall()
}
func updateEightBall() {
randomNumber = Int.random(in: 0...4)
eightBallDisplay.image = UIImage(named: eightBallArray[randomNumber])
}
}
Awesome! I've clearly come a long way if I can do that without any step by step help from Angela!
*8 minute pause
*8 minute pause
Practice - various
So I am only skimming through as this should be familiar.
One interesting thing already about operands is you need the equal space before and after the =. So none or one space! I always go for one. It needs to have balance - zen-like (Bob Lee).
Functions

Finished (approx 1 hour total)
So I am only skimming through as this should be familiar.
One interesting thing already about operands is you need the equal space before and after the =. So none or one space! I always go for one. It needs to have balance - zen-like (Bob Lee).
Functions

Select the code, then do the above so comment out in one go. That is very cool!
OK, rest of functions stuff was fine - all logical and just skipped through.
Comments
Post a Comment