jaywcjlove / jaywcjlove/swiftui-example
删除所有 Core Data 数据
- Dominant language
- Swift
- Stars
- 661
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
```swift
let entities = PersistenceController.shared.container.managedObjectModel.entities
for entity in entities {
if ((entity.name) != nil) {
let deleteFetch = NSFetchRequest(entityName: entity.name!)
let deleteRequest = NSBatchDeleteRequest(fetchRequest: deleteFetch)
do {
try viewContext.execute(deleteRequest)
try viewContext.save()
} catch {
print ("There was an error")
}
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided Swift snippet and trace PersistenceController.shared, managedObjectModel, and viewContext in the repository. Clarify where this behavior should live and what “delete all Core Data data” should cover; done means the agreed deletion behavior is implemented and verified against the project’s existing usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- database, mobile
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100