Re: CoreData, reset a persistent store
Re: CoreData, reset a persistent store
- Subject: Re: CoreData, reset a persistent store
- From: Pierre Chatelier <email@hidden>
- Date: Wed, 15 Nov 2006 23:20:39 +0100
[fetchRequest setPredicate:[NSPredicate
predicateWithFormat:@"SELF != nil"]];
May I ask what the purpose of this line is?
This is the predicate I use to fetch all objects (in order to
delete them afterwards).
It's utterly unnecessary and probably not right. Get rid of it. :-)
You're right, this is not necessary. I used to believe that a
predicate was required, but it's not the case.
Thanks to that discussion, I now understand better the difference
between faulting and internal-caching of CoreData, but it does not
change the problem.
My problem is still to clear my persistent store without fetching data.
More precise times :
//the code
[managedObjectContext lock];
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription
entityForName:@"CachedFeatures"
inManagedObjectContext:managedObjectContext]];
NSLog(@"fetch");
NSEnumerator* allObjectsEnumerator = [[managedObjectContext
executeFetchRequest:fetchRequest error:&error] objectEnumerator];
NSLog(@"delete");
id object = nil;
while((object = [allObjectsEnumerator nextObject]))
[managedObjectContext deleteObject:object];
NSLog(@"save");
[managedObjectContext save:&error];
NSLog(@"done");
[managedObjectContext unlock];
//the log (see the durations : fetch is 4 seconds : that's a lot, and
save is 7 seconds ! (that's for ~8000 objects))
2006-11-15 23:17:16.842 MyApp[2799] fetch
2006-11-15 23:17:20.576 MyApp[2799] delete
2006-11-15 23:17:20.721 MyApp[2799] save
2006-11-15 23:17:27.805 MyApp[2799] done
Pierre
_______________________________________________
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
References: | |
| >CoreData, reset a persistent store (From: Pierre Chatelier <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: Elise van Looij <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: Pierre Chatelier <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: Elise van Looij <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: Elise van Looij <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: "Marcus S. Zarra" <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: "I. Savant" <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: Pierre Chatelier <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: "Marcus S. Zarra" <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: Pierre Chatelier <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: "I. Savant" <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: Pierre Chatelier <email@hidden>) |
| >Re: CoreData, reset a persistent store (From: "I. Savant" <email@hidden>) |