Why are these objects still faults?
Why are these objects still faults?
- Subject: Why are these objects still faults?
- From: Gideon King <email@hidden>
- Date: Tue, 19 Jul 2011 15:21:32 +1000
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