• 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: Why are these objects still faults?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why are these objects still faults?


  • Subject: Re: Why are these objects still faults?
  • From: Heath Borders <email@hidden>
  • Date: Tue, 19 Jul 2011 08:05:30 -0500

Is your topic node self-referential? Maybe CoreData doesn't prefetch
circular references.

-Heath Borders
email@hidden
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Jul 19, 2011 at 12:21 AM, Gideon King <email@hidden> wrote:
> Hi, I'm doing a fetch of some objects like this:
>
> entity = [NSEntityDescription entityForName:kNMTopicNodeEntityKey inManagedObjectContext:[self managedObjectContext]];
> request = [[NSFetchRequest alloc] init];
> [request setEntity:entity];
> [request setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObjects:@"topic",@"view", nil]];
>
> results = [[self managedObjectContext] executeFetchRequest:request error:&error];
> if (results) {
>        log4Debug(@"Loaded %d topic nodes", [results count])
> }
> [request release];
>
>
> The log tells me id loaded my 2,000 topics.
>
> Then later, I do the following:
>
> // This is an array of topic nodes - the things that I have just fetched
> NSArray *allTopics = [map.rootTopicNode allDescendantTopicNodesIncludingSelf];
>
> NSSortDescriptor *sd = nil;
> if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) {
>        sd = [NSSortDescriptor sortDescriptorWithKey:@"view.zIndex" ascending:YES];
> } else {
>        sd = [[[NSSortDescriptor alloc] initWithKey:@"view.zIndex" ascending:YES] autorelease];
> }
>
> for (NMTopicNodeMO *node in [allTopics sortedArrayUsingDescriptors:[NSArray arrayWithObject:sd]]) {
>        Do stuff....
> }
>
>
> But this was running really slowly, so I commented out the above couple of lines, and did the following check:
>
> for (NMTopicNodeMO *ttn in allTopics) {
>        if ([ttn isFault]) {
>                log4Debug(@"Node is a fault");
>        }
>        if ([ttn.view isFault]) {
>                log4Debug(@"View is fault");
>        }
> }
>
> ...and it told me that the view was a fault for every topic node (but none of the topic nodes were faults)!
>
> But I told it to pre-fetch the view relationship. Any ideas why it wouldn't work?
>
>
>
> TIA
>
> Gideon
>
>
>
>
>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Why are these objects still faults?
      • From: Gideon King <email@hidden>
References: 
 >Why are these objects still faults? (From: Gideon King <email@hidden>)

  • Prev by Date: Optimizing a loop
  • Next by Date: Re: Optimizing a loop
  • Previous by thread: Re: Why are these objects still faults?
  • Next by thread: Re: Why are these objects still faults?
  • Index(es):
    • Date
    • Thread