• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: coredata and loooooooooooooooong waits
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >coredata and loooooooooooooooong waits (From: Benjamin Salanki <email@hidden>)

  • Prev by Date: keypress events + responder chain
  • Next by Date: Re: coredata and loooooooooooooooong waits
  • Previous by thread: coredata and loooooooooooooooong waits
  • Next by thread: Re: coredata and loooooooooooooooong waits
  • Index(es):
    • Date
    • Thread