Re: coredata and loooooooooooooooong waits
Re: coredata and loooooooooooooooong waits
- Subject: Re: coredata and loooooooooooooooong waits
- From: Jakob Olesen <email@hidden>
- Date: Tue, 17 Oct 2006 10:34:26 +0200
On 17/10/2006, at 10.00, Benjamin Salanki wrote:
- (NSArray*)arrangedObjectsForStore:(NSManagedObject*)store
{
NSManagedObjectContext * moc = [[NSApp delegate]
managedObjectContext];
NSEntityDescription * entityDescription = [NSEntityDescription
entityForName:@"storeEntity" inManagedObjectContext:moc];
NSFetchRequest * request = [[[NSFetchRequest alloc] init]
autorelease];
[request setEntity:entityDescription];
NSPredicate *predicate = [NSPredicate
predicateWithFormat:@"storeID = %d", [[store
valueForKeyPath:@"storeID"] intValue]];
[request setPredicate:predicate];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
initWithKey:@"storeID" ascending:NO];
[request setSortDescriptors:[NSArray
arrayWithObject:sortDescriptor]];
[sortDescriptor release];
NSArray* result = [moc executeFetchRequest:request error:nil];
I can't tell exactly, but isn't this fetch request retrieving your
"store" object? The one you already have? What is the point of that?
result = [[[result objectAtIndex:0] valueForKeyPath:@"storeClips"]
allObjects];
This gives you an array of clips, all potentially faults.
result = [result sortedArrayUsingDescriptors:[NSArray
arrayWithObject:[ autorelease]]];
This fires the faults one at a time. Very slow.
Just execute a fetch against the clip entity directly, using the
inverse relationship:
NSFetchRequest * request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:[NSEntityDescription entityForName:@"clipEntity"
inManagedObjectContext:moc]];
[request setPredicate:[NSPredicate predicateWithFormat:@"store = %
@", store]];
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc]
initWithKey:@"clipID" ascending:NO];
[request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];
NSArray* result = [moc executeFetchRequest:request error:nil];
And don't ignore the error...
_______________________________________________
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