Sandra L Course Part 2 (lectures 11 to 15)

Before I begin the second part of Sandra's course, I made a couple of final (I know that I should just leave it!) tweaks to How Many Letters. One flaw was that the number in the text box would still be there after clicking the button. That's fixed now! Was actually quite easy - a function that basically changed the value in the text box to an empty string. Also, I added a button with a segue to an information page. 

Start Time - 21:24

So I'm cracking on with Sandra's 'easy' course - the first bit was anyway. Hopefully it'll be more challenging soon but not make the giant conceptual leaps that Bob's code did!

Collection Types: Arrays

var numbers: [Int] = []


numbers.append(4)

All fine to be honest. 

There are various in-built functions with these that you can apply e.g. remove at last, remove all, count etc. 

This is all VERY easy. I'm a bit concerned! Going to crank up the speed...

Dictionaries

Main difference of course is the use of the key-value pair. It doesn't use the index system like arrays does (unless you specify that yourself!). 

Values are also optionals. Unwrapping is needed to get the values. 

Functions

Key point here - make functions verbs. Rather than 'hello'. Do 'sayHello'. So in my app, 'checkAnswer' was a good name of a function!

Return Type

OK, before she does the code for checking if a number is greater than I will do that on my own first....

let focusNumber = 5

func isNumberGreater(number: Int) -> Bool {
    
    return number > focusNumber
    
    
}

isNumberGreater(number: 7)

Easy. I didn't even need to bother with an if statement! I could have of course but there was no need. 

Paused at 21:48

Continued at 22:20

Parameters - making these readable is the key thing here. 

For in loop - used within an array in a function.


The rest of this - easy peasy use of functions to add, subtract etc. 

Finish Time - 22:23 (27 minutes total)

So didn't quite make it to the challenges. This was all VERY easy. A couple of useful nuggets - functions as VERBS and how arrays have indices as opposed to keys but that was not exactly new. This really is the basics of Swift before anything of use happens. Challenges next - they'll be fun at least I'm sure!

Comments

Popular posts from this blog

*Xcode Project Entry 2* F1 Quiz - part 1

Angela Yu Course Part 10 (up to lesson 112)

Angela Yu Xcode 12 Course - Part 7 (lectures 74 to 79)