Contained in: Your Second iOS & SwiftUI App
swiftui
iOS & Swift
Your Second iOS & SwiftUI App
Nov 4 2021 · Video Course (2 hrs, 0 mins)
…knowledge you’ve gained from creating a SwiftUI app, and learning the basics of Swift, to create a more complex app: one to track your book collection…
iOS & Swift
Introduction
Nov 4 2021 · Lesson
Learn what’s in store for you as you build Your Second iOS and SwiftUI App. This course builds on the Your First App, and Programming in Swift courses…
iOS & Swift
Modal Views
Nov 4 2021 · Lesson
Step 1, we’re going to create that dictionary I mentioned earlier to store our book images. We’re going to be using SwiftUI’s Image type for that. So, in Library.swift, import SwiftUI at the top. import SwiftUI And then add a new images variable - a dictionary that uses…
iOS & Swift
Models & Views
Nov 4 2021 · Lesson
…talked about earlier. Title and Author? Both constants and strings. let title: String let author: String It’s going to be helpful for our SwiftUI previews to be able to give books default values for those properties, but we don’t necessarily need them hardcoded into the type here. Instead…
iOS & Swift
SF Symbols
Nov 4 2021 · Lesson
Review how to add SF Symbols in SwiftUI, and dynamically add an SF Symbol based on a book’s title…
iOS & Swift
Conclusion
Nov 4 2021 · Lesson
…review some of what you’ve accomplished along the journey of creating Your Second iOS and SwiftUI App. There’s a new learning path in store for you, next…
iOS & Swift
List Rows
Nov 4 2021 · Lesson
SwiftUI List View is the backbone of the app you’re going to be creating the UI for in this course. Before we get into Xcode, let’s take a high-level look at what a List is, and how it works. A List is a special type of view…
iOS & Swift
Observable Objects
Nov 4 2021 · Lesson
Combine makes it easy to take an object, observe changes to its properties, and react to those changes, in SwiftUI…
iOS & Swift
Conclusion
Nov 4 2021 · Lesson
…able to do with lists already, and get a couple of ideas for what you can start thinking about in order to apply SwiftUI Lists in the future…
iOS & Swift
Sections
Nov 4 2021 · Lesson
…library has any sorted books for it. var body: some View { if let books = library.sortedBooks[section] { } } When there are books, we’ll use SwiftUI’s Section view. Any because we’ve got our own “Section” type, you’ll need to disambiguate using the framework name. if let books = library.sortedBooks[section…
iOS & Swift
Environment
Nov 4 2021 · Lesson
Book] { booksCache } func addNewBook(_ book: Book, image: UIImage?) { And as you’ve seen with Book , when you change a struct to a class, in SwiftUI, you very likely should make it an Observable Object, too. class Library: ObservableObject { The properties that you mutate are again, very likely , going to need…
iOS & Swift
Navigation
Nov 4 2021 · Lesson
…this episode, let’s just get some basics hooked up and aim for this: We’ll call this the DetailView , and create a new SwiftUI file for it, at the bottom of the Views group. Whenever I start a new file, I select all with command-A and then…
iOS & Swift
Image Binding
Nov 4 2021 · Lesson
Book Images currently only display symbols. That’s all we’ve told them to do so far! So, let’s supply them with optional SwiftUI Images. You can call the constant image . struct Image: View { let image: SwiftUI.Image? let title: String We’ve got errors now because the struct…
iOS & Swift
Model Objects
Nov 4 2021 · Lesson
…book, so we’ll need it to be var , not let . 🟩var🟩 book: Book But as you see, the toggling is still not possible. SwiftUI offers multiple solutions to this problem, such as using State , and Binding , which work with value types, like Book is. But we’re going…
iOS & Swift
Introduction
Nov 4 2021 · Lesson
Welcome to the final part of Your Second iOS and SwiftUI App! You’ve got a prettier, more custom-looking app, now. But we have some features left to implement. We still need to be able to add and remove books from our library, reorganize them, and sort them into…
iOS & Swift
Swipe Actions
Nov 4 2021 · Lesson
ObjectWillChangePublisher powers ObservedObject and EnvironmentObjects in SwiftUI. Use it to propagate ObservableObject changes to collections…
iOS & Swift
Delete & Move Rows
Nov 4 2021 · Lesson
MENU_TOKEN@*//*@PLACEHOLDER=Code@*/ /*@END_MENU_TOKEN@*/ }) .labelStyle... } You don’t need this “perform” here; you can use trailing closure syntax as usual in SwiftUI. BookRow(book: $0) } .onDelete { indexSet in } } So, what is this indexSet that onDelete gives us? In theory, onDelete could be providing you multiple integers…
iOS & Swift
Challenge: View Reuse
Nov 4 2021 · Lesson
…here because I’m using it in more than one place in the project. It doesn’t belong in ContentView anymore. import SwiftUI struct TitleAndAuthorStack: View { let book: Book var body: some View { VStack(alignment: .leading) { Text(book.title) .font(.title2) Text(book.author) .font(.title3) .foregroundColor(.secondary) } .lineLimit(1) } } extension Book…
iOS & Swift
Environment Values
Nov 4 2021 · Lesson
…environment objects are a really nice SwiftUI feature, for keeping the code that connects views as simple as possible. But the environment is not just a place for model objects! An environment is a storage container for potentially any information that multiple views need to function. One piece of potentially…
iOS & Swift
Challenge: New Book Sheet
Nov 4 2021 · Lesson
…over the auto-generated code in the new file. I also needed to move the PHPicker import. /// THE SOFTWARE. import class PhotosUI.PHPickerViewController import SwiftUI And to get a preview going, I used a default book and nil image binding. ReviewAndImageStack(book: .init(), image: .constant(nil) That looked better with some…