NSComparisonPredicate and floats
NSComparisonPredicate and floats
- Subject: NSComparisonPredicate and floats
- From: Wolfgang Berberich <email@hidden>
- Date: Fri, 16 Jun 2006 00:40:09 +0200
Hi list,
I don't know what's going on but it seems to me that CoreData
NSComparisonPredicate is not able to compare floats in a fetch
predicate.
Taken from a fetch all dump I have this example-object actually
stored in the SQL database:
<NSManagedObject: 0x43d8e30> (entity: GeoBitmap; id: 0x43ce490 <x-
coredata://00F85D92-5D2D-4F8B-80A4-7FA764848D65/GeoBitmap/p4> ; data:
<fault>)
minLat: 45.90417098999023
Where the value above for minLat is a [testObject
valueForKey:@"minLat"] and minLat is of type float in the model.
Now I build a fetch predicate to catch this object in the same context:
NSExpression *lhs = [NSExpression expressionForKeyPath:@"minLat"];
NSExpression *rhs = [NSExpression expressionForConstantValue:
[NSNumber numberWithFloat:45.92]];
predicate = [NSComparisonPredicate predicateWithLeftExpression:lhs
rightExpression:rhs
modifier:NSDirectPredicateModifier
type:NSLessThanOrEqualToPredicateOperatorType
options:0];
If I now execute this fetch request I do not get any results back
from the executeFetchRequest, nor something in the error object.
Weird is, that if I fetch with 46.92 in the rhs expression, I do get
results.
But as of my understanding the expression (45.90417098999023 <=
45.92) is as TRUE as (45.90417098999023 <= 46.92)
Did I oversee any type-attributes for NSExpression or
NSComparisonPredicate?
Any suggestions? Same problems?
Thanks for any help,
-berbie.
_______________________________________________
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