Lecture 6: Protocols Shapes

Stanford published this video item, entitled “Lecture 6: Protocols Shapes” – below is their description.

Lecture 6 of Stanford’s CS193p SwiftUI development course given during the Spring of 2021 finished off the discussion of the Swift Type System with an explanation of perhaps the most important kind of type in Swift: protocols. We touch on a number of protocol concepts, including a “constrains and gains” conceptualization of protocol extensions, the use of generics and protocols together, and protocol inheritance. After combining the concepts of protocols and generics in the Memorize game to size the cards to fit the available space on screen by creating an AspectVGrid, the lecture moves on to the topic of drawing arbitrary shapes using the Shape protocol. We take a look back at previously employed modifiers to Shape like .fill() which we can now more deeply understand through our studies of generics and protocols. We conclude this lecture by enhancing our Memory game to draw the pie-shaped countdown timer, using a custom Shape and ViewBuilder, which will be animated in the next lecture.

Stanford YouTube Channel

Got a comment? Leave your thoughts in the comments section, below. Please note comments are moderated before publication.

Leave a Comment