Lynda Course - Swift 5 Essential Thinking (Part 1)

All signed up! It's actually through LinkedIn - a site I've never needed to use before. But all of the content of Lynda is on there; I have it free for a month, then decide if I want to continue it! If I do, it is either £15 a month for an annual subscription, or £25 for the monthly. I'm thinking annual, as there is new content all the time added from Lynda! So, exiting stuff!

I'm naturally going to start with the 'Swift 5 Essential' course. Where else! So the perfect time to consolidate what I know (again!!) but with the Swift 5 updates all in mind. I need to go through this, as well as any other 'beginner' level courses. Let's go for it!

Start Time - 13:28

Introduction

OK, this is not a programming fundamental course. Good! I am not brand new to programming and don't need to go further back than this. So it is not for complete novices basically. Good, all on playgrounds first, which is what I need!

1. Getting Started

Swift is Compiled programming language. Changeover from Objective C has been a smooth gradient!

Prior to 2014, all iOS was written in Objective C. The Swift and Xcode versions have kept coming.

Version 2.0 of Swift was a big upgrade and 2.2 was open source - continued to be developed! Swift 3 and 4 both coming out in autumns of their years. Swift 5.0 has been from early 2019.

Getting Xcode - no need of course!

Cool, they have produced the playgrounds already, so I can work directly on those. In case they don't run, you can change back to run manually - if too much loading time etc. All of that seems fine. Challenges, excellent!

2. Getting To Know Your Data

Variables and Constants

Not going to type much unless useful stuff to reinforce that I don't already know well.

Putting all on a line - must be same type!\

Type Safety and Inference

Type inference - all good!

Type annotation - making it explicit what type; needs to be specified. Not assigning a value.

You can do both! But no need.


Logging and Commenting

Use of // etc. Holding onto the command and /. Use of multi-line comment. /* to */.

So logging is printing. That just gives the display output - for the coder.

Swift Operators

BODMAS etc.

Compound assignments: += or -= etc. This is the shorthand basically.

Modulo. The %.

Strings

A collection of characters strung together. Concatenation and String Interpolation I am well used to.

To print the string, it needs a value, even if that is an empty quotation marks.

You can do various things with strings like count, isEmpty...

Insert - not so sure about that - but not going to worry for now.

The remove, removeAll etc.

Split is cool! It actually takes account of what has been added in and separates them out into strings for an array! Could be useful.

Type Conversions

I'm all over this. No problems going from Int to Double, vice versa. Doesn't work so easily going from String to a number of course.

A note for going from double to Int - no rounding! It just chops off the decimals.

I know about trying to compute with different types - doesn't work.

Bools and Logical Operators

Use of ! for opposite etc. The && and the ||.

Optionals

Just a recap -

// Creating optionals
var someValue: Int?

print(someValue!)

var stringOptional: String? = "This is a string optional"



// Forced unwrapping


print(stringOptional!)

A key point about being careful with FU - you have to be 100% confident that there is a value. If not, the system will crash!

FU actually defeats the purpose of having optionals in the first place - the point is that they may contain a value or may have nil.

Accessing Documentation

Use of command button with right click.

Challenge!

Yes! This is the last bit I will do for now.



Let's do these...

// 1

var characterName = "Bob", weaponClassification = "Knife"

// 2

characterName += "- the loner"

// 3

var currentMana = 76.3

// 4

var manaPercentage = String(currentMana / 100)

// 5

var debugStats = "Character name: \(characterName)\nCurrent Mana: \(currentMana)\nMana Percentage: \(manaPercentage)"


// 6
var questAccepted = true, canQuest = false
// 7

var questStatus = questAccepted && canQuest

// 8

debugStats.append(contentsOf: "\nQuest status: \(questStatus)")


print(debugStats)


Only one thing I did that was unnecessary that I fixed - I converted the questStatus to a string initially, but didn't need to as it is within string interpolation.

Great stuff!

Finish Time - 14:39 (1 hour 11 minutes)

A good little recap! Nothing majorly knew but useful to go over the basics again. In theory, I will need a maximum of a week on this course. It means I can go over more complex stuff within this month's free trial. Then, I can decide if the content is worth paying for.



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)