Your Second iOS & SwiftUI App

Nov 4 2021 Swift 5.5, iOS 15, Xcode 13

Part 2: Data Flow

16. Model Objects

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See versions

See course reviews

See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 15. Challenge: Image Deletion Button Next episode: 17. Observable Objects

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

In this episode, you’re going to put the finishing touches on your book model!

  let author: String
  var microReview: String

  init(title: String = "Title", author: String = "Author") {
  var microReview: String

  init(
    title: String = "Title",
    author: String = "Author",
    microReview: String = ""
  ) {
    self.title = title
    self.author = author
    self.microReview = microReview
  }
  var microReview: String
  var readMe: Bool

  init(
    microReview: String = "",
    readMe: Bool = true
  ) {
    self.title = title
    self.author = author
    self.microReview = microReview
    self.readMe = readMe
  }
HStack {

TitleAndAuthorStack(...)
}
HStack(spacing: 16)
    Button {

    }
    Button {

    } label: {
      Image(systemName: <#T##String#>)
    }
  }
Image(systemName: book.readMe ? "bookmark.fill")
"bookmark.fill" : "bookmark")
    } label: {
      Image(systemName: book.readMe ? "\(bookmark).fill" : bookmark)
        .font(.system(size: 48, weight: .light))
    }
    Button {
      book.readMe.toggle()
    } label: {
  🟩var🟩 book: Book
class Book: Hashable {
class Book: Hashable {
extension Book: Equatable {

}
    self.readMe = readMe
  }
}

extension Book: Equatable {
  static func == (lhs: Book, rhs: Book) -> Bool {
    <#code#>
  }
}
  static func == (lhs: Book, rhs: Book) -> Bool {
    lhs === rhs
  }
public func === (lhs: AnyObject?, rhs: AnyObject?) -> Bool {
return ObjectIdentifier(l) == ObjectIdentifier(r)
class Book {
    self.readMe = readMe
  }
}

extension Book: Hashable {

}

extension Book: Equatable {
extension Book: Hashable {
  func hash(into hasher: inout Hasher) {
    <#code#>
  }
}
  func hash(into hasher: inout Hasher) {
    hasher.combine(<#T##value: Hashable##Hashable#>)
  }
hasher.combine(ObjectIdentifier(self))
hasher.combine(ObjectIdentifier(self))
extension Book: Hashable, Identifiable {
hasher.combine(id)
List(library.sortedBooks) { book in