Skip to content

Commit 055ea46

Browse files
committed
Add PersistentContainerStorage.delete(_:for:)
1 parent f0206a5 commit 055ea46

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Sources/CoreDataModel/NSPersistentContainer.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ public actor PersistentContainerStorage: ModelStorage, ObservableObject {
164164
}
165165
}
166166

167+
public func delete(_ entity: EntityName, for ids: [ObjectID]) async throws {
168+
defer { objectWillChange.send() }
169+
try await performBackgroundTask { (context, model) in
170+
try context.delete(entity, for: ids)
171+
}
172+
}
173+
167174
private func performBackgroundTask<T>(
168175
schedule: NSManagedObjectContext.ScheduledTaskType = .immediate,
169176
_ task: @escaping (NSManagedObjectContext, NSManagedObjectModel) throws -> T

0 commit comments

Comments
 (0)