Re: Recommended way to save NSPredicates in Core Data store?

2018-08-15 Thread Ken Thomases
On Aug 15, 2018, at 6:15 PM, Demitri Muna  wrote:
> 
> I'm building an interface that contains an NSPredicateEditor (think iTunes 
> smart playlists), and I want to save the predicate in a Core Data store. What 
> is the recommended way to do this? Serialize the NSPredicate object and save 
> it as a blob? Break apart the predicate into one or more NSExpressions (left 
> hand value, operator, right hand value) and reconstruct the predicate? I can 
> think of several possibilities, but am wondering what is the path of least 
> resistance (and, I suppose, most binding-friendly!).

Serializing the predicate (using NSKeyedArchiver) seems obviously the right way 
to go.  Any other approach is just reinventing serializing it in a worse way.

You can create a custom value transformer (subclass of NSValueTransformer) to 
automatically archive and unarchive.  Use that on your binding.

Regards,
Ken

___

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


Recommended way to save NSPredicates in Core Data store?

2018-08-15 Thread Demitri Muna
Hi,

I'm building an interface that contains an NSPredicateEditor (think iTunes 
smart playlists), and I want to save the predicate in a Core Data store. What 
is the recommended way to do this? Serialize the NSPredicate object and save it 
as a blob? Break apart the predicate into one or more NSExpressions (left hand 
value, operator, right hand value) and reconstruct the predicate? I can think 
of several possibilities, but am wondering what is the path of least resistance 
(and, I suppose, most binding-friendly!).

Cheers,
Demitri

___

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