Re: CoreData, reset a persistent store
Re: CoreData, reset a persistent store
- Subject: Re: CoreData, reset a persistent store
- From: Elise van Looij <email@hidden>
- Date: Wed, 15 Nov 2006 17:47:29 +0100
Op 14-nov-2006, om 17:20 heeft Pierre Chatelier het volgende geschreven:
No, at runtime I don't think that would be a good idea. You might
want to take a look at Apple's NSPersistentStoreCoordinator Class
Reference.
That's what I did, but there is no method to clear a persistent store.
But as far as the cache growing to gigantic proportions, I don't
think you need to worry about that.
I do worry. I don't want my cache file to take dozen of GB, even if
only a part of it is in memory (thanks to faulting).
So far, what I do is:
-lock the managed object context
-reset the managed object context to clear all pending changes
-call removePersistentStore:error on the PersistentStoreCoordinator
-remove the underlying file with NSFileManager
-call addPersistentStoreWithType:configuration:URL:options:error on
the PersistentStoreCoordinator to re-create the file
-unlock the managed object context
Sorry, I don't know enough about memory management to help you with
that. What I don't quite understand from your solution, though, is
why you want to discard all the pending changes. If you don't want to
have any pending changes, don't allow your users to make any changes.
That way you won't have to worry about throwing them away.
Elise van Looij
_______________________________________________
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