• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
re: NSExpression with constant NSData value crashes Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: NSExpression with constant NSData value crashes Core Data


  • Subject: re: NSExpression with constant NSData value crashes Core Data
  • From: Ben Trumbull <email@hidden>
  • Date: Fri, 22 May 2009 13:54:12 -0700

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 (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


  • Follow-Ups:
    • Re: NSExpression with constant NSData value crashes Core Data
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: entity name not found when model is in private framework
  • Next by Date: Re: NSExpression with constant NSData value crashes Core Data
  • Previous by thread: Re: getting a point from an array of NSValue CGPoints
  • Next by thread: Re: NSExpression with constant NSData value crashes Core Data
  • Index(es):
    • Date
    • Thread