Skip to content

Commit 198be73

Browse files
committed
Updated readme
1 parent 6eeb1ea commit 198be73

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Lightweight Active-record-ish pattern.
1313
- [Installation](#installation)
1414
- [Example App](#example-app)
1515
- [Documentation](#documentation)
16+
- [Predicate](#predicate)
17+
- [`NSManagedObject` Extensions](#nsmanagedobject-extensions)
1618
- [Logging](#logging)
1719
- [Quick Start with SwiftUI](#quick-start-with-swiftui)
1820

@@ -64,9 +66,21 @@ Instead of
6466
NSPredicate(format:"color = %@ and city = %@", argumentArray:["Blue", city])
6567
```
6668

69+
### `empty()`
6770

71+
Returns a new, non-nil, `NSPredicate` object that will match every single row in the database.
6872

69-
## 'NSManagedObject' Extensions
73+
> This is especially helpful with:
74+
> 1. The [@FetchRequest property wrapper](https://developer.apple.com/documentation/swiftui/fetchrequest). Using a nil predicate can cause unexpected behavior if you dynamically assign or edit the predicate at runtime.
75+
> 2. Other Core Data quirks around nil predicates and updating when you do fancy stuff.
76+
>
77+
> Before: `@FetchRequest(sortDescriptors: [], predicate: nil)`
78+
> After: `@FetchRequest(sortDescriptors: [], predicate: Predicate.empty())`
79+
80+
81+
82+
83+
## `NSManagedObject` Extensions
7084
### `findOrCreate`
7185

7286
Finds an instance of the `NSManagedObject` that has a column (property) matching the passed value. If it doesn't exist in the database, creates one, and returns it.

0 commit comments

Comments
 (0)