Mobile App Development 2022W Lecture 7
Video
Video from the lecture given on February 2, 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 7 --------- Midterm will be on Assignments 1 & 2 Assignment 2 is on tutorials 3-5 - Tutorial 5 will be textAnalyzer-3, which is using UIKit rather than SwiftUI Midterm format will be the same as the assignments - submit a text file that will be split up for grading For A1, if you don't follow the format, you'll get a stern warning message from me. After A1 (for A2, midterm, and later), not following the directions can get you a zero grade. Image: a view to display an image in the app's assets AsyncImage: loads image in the background from the Internet and then displays it - note that accessing resources over the net can take arbitrary amounts of time, so you have two choices: wait for the load to finish, or load it in the background - "sync" refers to synchonous I/O, i.e., blocking I/O (wait until the operation finishes) - in many online contexts, we more do "async", or asynchronous I/O (so input and output happens in the background while our program does other things) Note that most of the I/O you've seen has been synchonous - on the line after "print", you can be sure the print had finished doing its work What's the key difference between JPEG and PNG images? - PNGs are lossless compressed (no information lost) <--- so will be bigger - JPEGs are lossy compressed (information lost) - JPEGs are normally used for photographs because what is lost isn't noticable to the human eye - PNGs are used for interface elements, as they are much simpler and compression artifacts are much more noticable - when people talk about "raw" images, those are images from a camera before they've been compressed (turned into JPEGs), so they are much larger but have all possible details Device screens run at different sizes and resolutions, so it is common to include assets at different scales so they can be properly optimized for different screens - ideally, though, you'd use vector formats for whatever you can, as those don't have a resolution: they look perfect at any resolution because they are defined from lines and areas, not pixels Adobe Photoshop or the GIMP are for images made of pixels (PNG, JPEG) Adobe Illustrator or Inkscape are for images made of vectors (SVG) PDFs are a container format that can contain vector and pixel data - good PDFs are mostly vectors Note that you can't treat AsyncImage as an Image directly - because initially there is no image at all! - you only get an image after the asset has loaded - you can display an alternate image while the loading happens, or just show something to indicate the asset is loading In Swift, struct's are immutable (class's are mutable) - but if you declare something with @State, that property becomes mutable (and has lots of other things going on underneath so views get updated when they are changed) AsyncImage is only available on MacOS 12 - so it is there in Monterey, but not Big Sur - I can't build things with AsyncImage to work on my mac! I have to compile as an iOS app and run in the simulator The @available decoration is needed when you use features that may not be available on some platforms