Posts

Showing posts with the label control flow

Ray Wenderlich Fundamentals Course - Part 2

Image
Yes! First consecutive entry for a little while. Good news - I have sorted out the UI stuff so I have Mac OS Catalina - the beta version. I've changed my account so I get to have the beta stuff basically - ahead of time. So when the actual update comes up, I will just get that for the 'normal Xcode'. Anyway, I want to complete the fundamentals course. It's been very, very basic so far. So will skim through the content and just get to the challenges. Also, I'm aiming for no more than an hour at a time, but in 2 possible stints today. So stint 1 is to get the next chapter done. Here we go! Start Time - 11:49 COLLECTIONS Tuples One thing to type - that you can assign multiple values in brackets to the entire tuple, then each of those values is saved separately. let wrestlingFacts = (name: "Kevin Owens" , didWin: true ) let ( name , wonMatch ) = wrestlingFacts So now 'name' and 'wonMatch' are their own values. I could use ...

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 7 (Lectures 26 to 31)

Image
So continuing with Control Flow! Going to do approximately an hour now - so that will be the rest of this chapter, then the next one on Strings.  Start Time - 13:20 If/else Just a catch up on this - skimming through! Simple example above. The use of else if as the alternative cases. Nested if statements - having an if statement with one that follows immediately. Simple. Switch Statements Again, I'm happy with this. Has to be exhaustive, is better for situations with numbers. Using several values for different cases - And this is with number ranges - Tuples with switch statements - Again, straightforward stuff. You just need to do the case with two values (as there are two - cars and weeks). In the above, there are closed values, the wildcard bit (underscore used). You can also use value binding by creating a value within the case  - So you then use those temp values that have been binned within the print statements. Where clause - can be u...

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 6 (lectures 40 to 47)

Image
Two days in a row - first time in a while. Boom! Yesterday was a really useful session, focusing on classes then applying it to a model. It made a few concepts clearer to me, especially the fact that custom types can be passed into parameters/arguments; THEN the object, when created, can be put into the function. Anyway, I said I'd start a new project next. Before I do that, I want to crack on with Sandra's Quiz Project - the next chapter in her course. THAT will be the project I will work on! Start Time - 13:13 Intro and Stack View Right so I have opened the project file then Sandra says that we can go from scratch. So I will actually do the same as that's the best way to learn! Reminder about the new position of the option button. Stack view needed! Vertical stack view put in. Constraints time. *Red - missing constraints *Yellow - conflicting constraints *Blue - all is OK! This is just to show that the label and button are like the 'children' of ...