Posts

Showing posts with the label While

Lynda Course - Swift 5 Essential Thinking (Part 3)

Image
So, predictably, it's been tough finding time this week. Knew it would happen with work becoming busier! So a quick-ish entry now. Next bit of Swift Essentials! Start Time - 20:46 4. Application Control Flow I love this! Probably my favourite aspect of Swift. Got enough time to complete this chapter as it's a short-ish one. var hp = 91 var maxHP = 100 // If statement (<, >, <=, >=, !=, ==) if hp < maxHP {     print ( "Health is lower than the max health!" ) } else if hp <= 50 {     print ( "Health is running seriously low!" ) } else {     print ( "Health is not registered" ) } Optional Binding   One interesting point is that the temporary value is only available within the if/let statement, not outside of that scope though! Another example with multiple values. Optional chaining -  if let _ = isShopOpen , let searchedItem = blacksmithShop [ "Shield" ], le...

Stephen DeStefano Swift 5 Course - Part 6 (Lectures 23 to 25)

Image
Yes cracking on! Got a bit of time this morning before heading to my Uncle's and Auntie's. I want to cover Optionals then Control Flow. All very doable! Let's go! Start Time - 08:19 Optionals So I know about these but good to go over! They're used in situations where they may not be a value stored. Nil means the absence of a valid object. You can do these for any type at all. Optional types are returned where there may not have been a value e.g. when converting from string number to actual int number. The question mark syntax. Good way of understanding this is that the ? QUESTIONS whether something may not have a value. So the question bit is key there! You can only use nil with optionals. Optionals can only be var as the values are likely to change. If you create an optional without an initial value then it automatically sets this to nil. Forced unwrapping Comparing the optional against nil.... That's not forced unwrapping - that's just ch...

Sandra L Course Part 3 (lectures 16 to 22)

Image
Well it's been a good few days! After so much success with my first proper app, it's been a shame not to capitalise on that. Having said that, I do feel recharged and ready to learn some more! My plan with Sandra's course is to keep with it for all of the recap. When it starts getting trickier, I'm going to work on an Xcode project for another app idea - got a few possibilities! So, let's continue with Sandra's course! Start Time - 13:29 Parameter Labels func add(number1: Int , number2: Int ) -> Int {          return number1 + number2 } add (number1: 4 , number2: 6 ) Again, easy stuff. The next step here is to use _ to have empty parameter labels.  OK - one useful distinction here between parameters and arguments. The argument is the external name - the one used outside of the code block. The argument label should read as a sentence e.g. using 'to' instead of 'name' in a sayHello function.  So "say hel...

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 8 (up to lesson 70)

Image
Second entry today - woohoo! Cracking on with Ray's guide to all the key language features of Swift. First up will be control flow for 8 lessons then 9 for functions and optionals. I want to get at least all of those done in this entry. Hopefully there will be some more challenges as these undoubtedly help me understand the information at a greater depth. I'm going to be going through the main info at a quicker speed: 1.5 x again. Ok here we go! While Loops var i = 1 while i < 10 {          print ( i )          i += 1 } In this example, numbers from 1 to 9 will be printed.  So the difference with repeat loops is that it executes the code the first time, no matter what... repeat {     print ( i )     i += 1 } while i < 10   Ray says that the first one is used generally more.  repeat {     print ( i )     if i == 5 { ...