how to remove all objects from Core Data

前端 未结 7 1450
我寻月下人不归
我寻月下人不归 2020-12-09 23:04

how can I remove all objects? I know I can remove one by

[managedObjectContext deleteObject:objToDelete];

is it possible to delete all wit

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 23:11

    You can also just tear down the stack (releasing the NSManagedObjectContext, NSPersistentStore and NSManagedObjectModel) and delete the file. Probably would be faster than iterating over your entire database and deleting each object individually.

    Also, it is unlikely they will provide this functionality in the future because it is easy to delete the file. However if you feel it is important then file a radar and let Apple know. Otherwise they won't know how many people want this feature.

提交回复
热议问题