Posts

Showing posts with the label motion detection

Angela Yu Xcode 12 Course - Part 5 (lectures 51 to 54)

Image
After a couple of days where I literally had no time to code, I am back! Cracking on with Angela's course. As before, for these projects I am just skimming through and working out any answers to her questions as I go. Right let's start! Start Time - 20:41 Arrays in Swift Image View - think of these as a picture frame. Something will go inside. So that is the code for changing the image view - using the property of image then the UIImage class. So that will make the left die show 'dice 2'. Of course the best way to do this would be to create a dice array. E.g. var diceArray = ["dice1", "dice2"...] Then have the random integer in the [] shown each time. Arrays - no need to go over this. I know they're the same type, start from index 0 etc. So instead of 1 in the square brackets, use the randomDiceIndex1 value. That will mean a random one each time. Same for both dice. Easy! DRY Principle Don't Repeat Yourself! OK th...