You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,8 +66,8 @@ NSPredicate(format:"color = %@ and city = %@", argumentArray:["Blue", city])
66
66
67
67
68
68
69
-
70
-
## `findOrCreate`
69
+
## 'NSManagedObject' Extensions
70
+
###`findOrCreate`
71
71
72
72
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.
73
73
@@ -88,7 +88,7 @@ let d = Drawing.findOrCreate(id: "123", context: viewContext)
88
88
*Tip: If you're using SwiftUI, adding a `String` column `id` plays nicely with `Identifiable`*
89
89
90
90
91
-
## `findButDoNotCreate`
91
+
###`findButDoNotCreate`
92
92
93
93
Same as `findOrCreate`, but returns `nil` if there is no object in the database.
94
94
@@ -99,15 +99,15 @@ if let d = Drawing.findButDoNotCreate(id: "10001", context: viewContext) {
99
99
}
100
100
```
101
101
102
-
## `countFor`
102
+
###`countFor`
103
103
104
104
Gets a count of objects matching the passed `Predicate`
105
105
106
106
```swift
107
107
let count = Drawing.countFor(Predicate("someField = %@", true), context: viewContext)
108
108
```
109
109
110
-
## `searchFor`
110
+
###`searchFor`
111
111
112
112
Gets all objects matching the passed `Predicate`
113
113
@@ -122,7 +122,7 @@ for drawing in results {
122
122
```
123
123
124
124
125
-
## `destroyAll`
125
+
###`destroyAll`
126
126
127
127
Removes all objects from Core Data.
128
128
*Deletes them from the context, and saves the context.*
@@ -230,5 +230,6 @@ struct ContentView: View {
230
230
## Todo
231
231
-[ ] Unit tests
232
232
-[ ] Option to disable automatic saving when using `destroyAll`
233
+
-[ ] Add docs on `NSPersistentContainer` agnosticity
0 commit comments