Mobile App Development 2022W Lecture 4: Difference between revisions

From Soma-notes
Created page with "==Video== Video from the lecture given on January 21, 2022 is now available: * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec04-20220121.m4v..."
 
 
Line 5: Line 5:
* [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec04-20220121.cc.vtt auto-generated captions]
* [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec04-20220121.cc.vtt auto-generated captions]
Video is also available through Brightspace (Resources->Zoom Meetings (Recordings, etc.)->Cloud Recordings tab).  Note that here you'll also see chat messages.
Video is also available through Brightspace (Resources->Zoom Meetings (Recordings, etc.)->Cloud Recordings tab).  Note that here you'll also see chat messages.
(Video links don't work now, will be fixed a bit later today.)


==Notes==
==Notes==

Latest revision as of 20:29, 21 January 2022

Video

Video from the lecture given on January 21, 2022 is now available:

Video is also available through Brightspace (Resources->Zoom Meetings (Recordings, etc.)->Cloud Recordings tab). Note that here you'll also see chat messages.

Notes

Lecture 4
---------

Remember that in swift, references by default always have a value
 - they won't have "nil"

But sometimes operations won't return a valid value
 - i.e., looking something up in a dictionary, getting user input

So swift forces us to handle the case of it being nil before it allows
us to use the data

The idea of optional types and unwrapping optional types is all about changing runtime errors (oops, the value is nil when it should have been something valid) into a compile time error.

Notice in Swift we don't normally deal with "exceptions"
 - errors are handled where they are generated generally

Any view can have @State variables

We use @Binding to share variables between views
 - one declares it with @State
 - the other references it using @Binding
 - The declaring one must then include the @Binding one, connecting
   the variables as part of the inclusion.