Re: CoreData, reset a persistent store
Re: CoreData, reset a persistent store
- Subject: Re: CoreData, reset a persistent store
- From: Chris Hanson <email@hidden>
- Date: Wed, 15 Nov 2006 21:12:21 -0800
On Nov 14, 2006, at 5:43 AM, Pierre Chatelier wrote:
I am wondering how to reset a persistent store used by a single data
model.
-A simple solution would be to fetch all objects and delete them;
this consumes much memory.
-I am not sure that deleting the file under the persistent store is
a good idea.
-the "reset" method of the managed object model is not designed for
that.
There's no such thing as "resetting" a persistent store. A persistent
store can have data inserted into it or deleted from it, but it can't
be "emptied."
Instead, you can just do the following:
(1) Make sure you have no existing instances of any managed objects
associated with that persistent store.
(2) Ask any persistent store coordinator to which your persistent
store has been added to remove it.
(3) Delete the underlying file corresponding to the persistent store.
Then you can add a new persistent store to any coordinator with the
same URL and get a new, empty persistent store at that URL as a result.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden