Error with core data fetch requests: subentitiesByName misapplied, and segfaults
Error with core data fetch requests: subentitiesByName misapplied, and segfaults
- Subject: Error with core data fetch requests: subentitiesByName misapplied, and segfaults
- From: Niko Matsakis <email@hidden>
- Date: Thu, 20 Jul 2006 16:58:03 +0200
Dear all,
I recently started hacking on a small "accounting" application using
Core Data. It contains almost no code yet, but I'm running into
crashes and other strange behavior when trying to use a fetch
request. What is most strange is that if I build the same fetch
request by hand, rather than using a stored fetch request, everything
works fine.
The code in question attempts to select all instances of the class
"Expense" that have a given payee; at first, the payee was set by
variable, but at the moment I have it hard-coded for testing purposes.
When I build the fetch request by hand, it seems to work. When I
execute a saved fetch request, I get the following error:
2006-07-20 15:15:20.087 drachma[849] *** -[NSKeyBindingManager
subentitiesByName]: selector not recognized [self = 0x33f6b0]
or one like it. Sometimes the class which does not recognize the
selector is a dictionary, other times a string. Sometimes I simply
get a SEGFAULT or BUS error.
I tried to create a new project but was unable to reproduce the problem.
Any ideas? I can't find *anything* online discussing this sort of flaw.
The project can be downloaded from http://smallcultfollowing.com/code/
drachma.tar.gz; it uses a few debugging print out routines from a
library, Oaxaca, that I've been accumulating. They are included. To
reproduce the problem, simply open, build and run the project, and
then click on the "Clear" button. This performs a query in two
different ways. You'll see that the first will work, and the second
(stored query) will fail.
The code performing the query itself is in "drachma/src/
DrachmaController.m" in the method "clearNewExpense:". Here is the
content of that method:
- (IBAction)clearNewExpense:(id)sender
{
// ... some irrelevant code skipped ...
// *** CONSTRUCT THE QUERY BY HAND ***
NSManagedObjectContext *moc = [_drachma managedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription
entityForName:@"Expense" inManagedObjectContext:moc];
NSFetchRequest *request = [[[NSFetchRequest alloc] init]
autorelease];
[request setEntity:entityDescription];
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"payee == %@", @"Migros"];
[request setPredicate:predicate];
NSError *error = nil;
NSArray *array = [moc executeFetchRequest:request error:&error];
// ** EXECUTE STORED QUERY (this fails) **
NSManagedObjectModel *model = [_drachma managedObjectModel];
NSFetchRequest *fetchRequest =
[model fetchRequestFromTemplateWithName:@"specific"
substitutionVariables:[NSDictionary
dictionary]];
array = [moc executeFetchRequest:fetchRequest
error:&error]; // ** EXCEPTION OCCURS
HERE **
}
It may be relevant that I use a distinct class for each type of
Entity. However, I have changed this back and forth and it seems to
make no difference either way.
Thank you for any help! I apologize for the scatter-brained email,
I'm at a bit of a loss as to how to proceed in debugging this. I
have reproduced it on multiple machines, but my attempts to narrow it
down have been unsuccessful. Still, I have spent a total of a few
hours working on the project, so it's a fairly constrained example
even as is.
Niko
_______________________________________________
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