Talking about the newly added CoreData dynamic FetchRequest filtering and sorting features in SwiftUI 3.0

insert image description here



Functional Requirements

SwiftUI projects backed by CoreData are becoming more common these days.

We know that displaying dynamically filtered and sorted data was a bit tricky prior to Swift 3.0.

However, since Swift 3.0, Apple has enhanced the function of FetchRequest for us, and we can now modify the filtering and sorting conditions of FetchRequest objects on the fly in SwiftUI.

insert image description here

In this blog post, you will learn:

  • How does SwiftUI support dynamic filtering and sorting of managed objects before SwiftUI 3.0
  • Enhanced FetchRequest object's native support for the above functions in SwiftUI 3.0


Functional Analysis

1. Workarounds before SwiftUI 3.0

In the old version of SwiftUI, although we can use the @FetchRequest wrapper in the view to easily read and write the managed objects in CoreData, it also brings a criticism: the filtering and sorting of FetchRequest cannot be dynamically modified.

在SwiftUI

Guess you like

Origin blog.csdn.net/mydo/article/details/123351033