core data - compound predicate fails with strange error
core data - compound predicate fails with strange error
- Subject: core data - compound predicate fails with strange error
- From: Warren Burton <email@hidden>
- Date: Sun, 1 Apr 2007 14:21:34 +0100
Hi
Im trying to construct a mixed predicate much like this
("abc" IN[cd] longDescription OR "abc" IN[cd] name) AND layer.level == 2
which gives me the following error after a fetch
2007-04-01 13:51:38.138 TigerTrout[9766] error - The file is not in
the right format. , The file might be corrupted, truncated, or in a
different format than you expect.
But oddly
"abc" IN[cd] longDescription AND layer.level == 2
or
"abc" IN[cd] name AND layer.level == 2
or
"abc" IN[cd] longDescription OR "abc" IN[cd] name
provide me with correct fetch results. So it seems to something to do
with the predicate having more than two terms but I cant think what.
The actual code follows below
Thanks
Warren Burton
<snip>
id arr;
id pred;
id fp = [self filterPredicate];
if(fp)
{
arr = [NSArray arrayWithObjects:[NSNumber numberWithInt:level],nil];
id sp = [NSPredicate predicateWithFormat:@"layer.level == %@"
argumentArray:arr];
id parr = [NSArray arrayWithObjects:fp,sp,nil];
pred = [NSCompoundPredicate andPredicateWithSubpredicates:parr];
}
else
{
arr = [NSArray arrayWithObjects:[NSNumber numberWithInt:level],nil];
pred = [NSPredicate predicateWithFormat:@"layer.level == %@"
argumentArray:arr] ;
}
NSLog(@"pred - %@",pred);
NSError *error = NULL;
[fetch setPredicate:pred ];
NSArray *results = [[[NSApp delegate] managedObjectContext]
executeFetchRequest:fetch error:&error];
if(error)
{
NSLog(@"error - %@ , %@ \n ** - %@",[error localizedFailureReason],
[error localizedRecoverySuggestion],[error localizedRecoveryOptions]);
}
</snip>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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