Posts

Showing posts with the label if statements

Nick Walter Swift 5 Course - Part 1 (lectures 1 to 15)

Image
Well, this has been the worst effort for a long, long time! An entire month! There's no point fretting about it - that will not achieve anything. I've felt a renewed sense of wanting to achieve with coding. At this point, it makes sense to switch to a new Swift 5 course, as the language has been updated. It will also give me a chance to consolidate and ensure my understanding of the basics is solid. Then I will resume with Angela's course! So not a cop out. OK, let's get stuck in! Start Time - 14:00 Just looking at Nick's course, there are 6 hours of content here. Perfect for the next few entries - possibly just even the next couple of days' worth. A lot will be the basics, but that's fine. Intro/Installing Xcode - skipping through all these! Don't need the Linux/Windows ones either. Swift Basics This is going from absolute beginner, so rather than totally skipping through and onto Intermediate, I'm going to just do a general skim over. S...

Chris Ching Course Part 1 (Data types, If/Switch statements, Loops and Functions)

Here we go! Back to Udemy and consolidating with this course from Chris Ching. Spending a couple of weeks on Treehouse has not proved fruitful, though it was interesting to look at properties, initializers and a few other aspects at a higher level. Anyway, coding is one of these things where my understanding needs to be topped up. A bit like going to the gym! Some bits will be intact but I need constant topping up to make it at its optimum.  Start time - 15:02 Data Types *Just skimming over this! Different types of data are stored on the data differently. If the system knows it is an int, then it allows different things to a string, double etc. Type inference - he hasn't mentioned this but there is no need to specify the type. Xcode figures that out. Converting types - var number = 4 number = String(4) var/let - know all about these. Rounding function. Use the round() with the variable in the brackets. If Statements *Again, skimming through! Something I nee...

Ray Wenderlich Course Part 4 (up to lesson 35)

Image
As promised I'm finding more time to code today! Not much else to say - let's go! How to Calculate the Difference So the challenge here is to see what is the difference is between the slider value and the target. Ray explains that we can't just do sliderValue - targetValue as the sliderValue could be higher. So one way would be to do an if statement! E.g. var difference = 0 if sliderValue > targetValue { difference = sliderValue - targetValue } else if targetValue > sliderValue { difference = targetValue - sliderValue } else { difference = 0 } Another way would be if difference is < 0 to then add that total again twice over...but that sounds more fiddly and less logical to me! Absolutely NAILED IT! Soooo satisfying! :) Next difference challenge - var difference = currentValue - targetValue   if   difference < 0  {                         differenc...

Angela Yu Course Part 10 (up to lesson 112)

Image
It's unlikely that I'll be able to do any Swift tomorrow as I'm going to Eastbourne today, for the weekend. So I can give half an hour now, maximum! Coding Challenge - Destini App! Choose your own adventure books! I used to ADORE these. Angela explains that these have had some sort of revival through the Lifeline games. It's very binary - yes/no mostly. I have my own experience of this based on WDC... Now the challenge is to complete the game! Having followed the first few instructions, which I found a bit confusing it must be said, I was about to surrender and see the answer. Then I managed to stop myself - I CAN do this, or at least have a good go! Even if I don't get the correct answer, it will be good practice to put what I know into practice. This is my weakness, which I keep coming back to - that when some problem solving is required, I fold far too quickly. So here is what I need to do: Let's break this down... I need to use the...