I needed to create a Core Data Mapping Model today.  The only value migration 
necessary was to negate a boolean.  It seems like one should be able to enter 
such a simple expression into the "Value Expression" column of "Attribute 
Mappings".  Reading the Predicate Programming Guide, I tried, in turn, these 
three…

   !$source.foo

   NOT $source.foo

   NOT($source.foo)

However, in each case, Xcode complained of an invalid expression.  At that 
point I gave up and did the only thing I know that works, which is to subclass 
NSMigrationPolicy, implement a method that negates a given NSNumber, and 
reference it in the expression…

    FUNCTION($entityPolicy, "negateBoolean:" , $source.foo)

It tested OK and is ready to ship.  But, for next time, is there an easier way 
to do this?

Thanks,

Jerry
_______________________________________________

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

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

Reply via email to