Mobile App Development 2021W Lecture 2

From Soma-notes

Video

Video from the lecture given on January 13, 2021 is now available.

Notes

Lecture 2
------------

Readings
  Swift Basics:
    https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html


TA's will be keeping track of participation, posting in cuLearn periodically
 - if you think you weren't given credit for a lecture, talk to a TA
 - note we have a record between the Teams chat and audio from lectures

SwiftUI terminology is similar to HTML/CSS, but this is because both come from terminology for GUIs, which come from terminology for printing (on paper)
 - look up TeX, in particular the TeXbook


Is swiftUI front end?
 - will answer later

Cross-platform development
 - environment I'm developing for is different from the one in which I write code
   - developing on MacOS, but code will run on iOS
 - typically difficult, but with modern IDEs it is almost seamless
   - almost!

@State variables
 - denotes variables that directly affect the interface
 - if their values change, the interface must be updated

$ notation
 - in SwiftUI, means a binding to the variable should be passed
 - functionally it is like a pointer, but much safer, ie pass by reference not value

"if let X"
 - checks whether X is nil or not
 - allows you to check for failed conversions, etc (e.g., if Double(s) finds that S
    was not a number)

If you say "F = Double(Fs)", F is not of type Double, it is of type Double?
 - it could be a double, or it could be nil
 - you can't use  it until you check, or you force usage with !
   - don't use !, because if you are wrong your program crashes

Code

lec02 xcode project