Your Second iOS & SwiftUI App

Nov 4 2021 · Swift 5.5, iOS 15, Xcode 13

Part 2: Data Flow

16. Model Objects

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

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

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 16. Model Objects

Equatable

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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