On 2009 May 17, at 15:10, Ben Trumbull wrote:

Core Data supports == and != searches against binary data.  You
should be able to just use a predicate like:

[NSPredicate predicateWithFormat:@"myTransformableAttribute = %@",
myGuidObject]

and have it "just work".

Read the above carefully!

myGuidObject is an NSData, right?  So when you make that predicate
with %@, it becomes a string description, complete with angle brackets
and a whitespace separating each group the four bytes.  Core Data is
actually comparing the ^descriptions^ of NSData objects.  Yuck!!

Uhm, No. %@ is the vararg specifier for an NSObject. - stringWithFormat: turns that into a string. Because - stringWithFormat: turns everything into a string. Kinda the point.

-predicateWithFormat: does NOT call -description randomly. Predicates are trees of first class objects, like an AST for a query. It does not turn objects into their textual representation before comparison.

Result: It worked fine with the XML store (Why??).  But when I switch
to the SQLite store, it crashes when Core Data sends a -UTF8String
message to the data object -- because it's expecting a damned
description string.  Took me several hours before I finally read Ben's
post very carefully and figured out why it was doing that.

This bug was fixed in 10.5.7

- Ben

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to