views:

220

answers:

3

Is there a quick way to clear all data of my CoreData without calling deleteObject for each entity in the model?

A: 

You can release all your NSPersistentStoreCoordinator and all you NSManagedObjectContest's then delete the file in the FS and recreate it.

Louis Gerbarg
A: 

Delete the persistent store on disk (after calling -[NSPersistentStoreCoordinator removePersistentStore:error:] for any persistent store coordinator that refers to the store). You probably also want to reset any NSManagedObjectContext instances that may have managed object instances from that store before removing and deleting the store on disk.

Barry Wark
A: 

my experience is this doesn't work on the iPhone. the MOC creates the persistent store automatically in the simulator, but doesn't do so on the device (OS 3.1.2). Am I missing something? I thought it was a two step process: you add the persistent store, then on your first save the ManagedObjectContext creates the underlying store, via the PersistentStoreCoordinator.

misbell