Is there any common way to decompose an expression created by [NSPredicate predicateWithFormat] to objects NSComprasionPredicate, NSExpression and other?
For below example need to disassemble into components.
[NSPredicate predicateWithFormat:@"(0 != SUBQUERY(collection, $x, $x.name == "Name").@Count)"];
+[NSPredicate predicateWithFormat:]is actually the front-end for a rather sophisticated parser. If you introspect the resultingNSPredicate, you’ll find that it’s not actually anNSPredicate, but either anNSComparisonPredicateor anNSCompoundPredicate.Both of those types of predicates have lots of handy methods for convenient introspection.
In other words:
NSPredicateis actually an “abstract” class. You’ll usually only ever deal with comparison or compound predicates. There are other kinds, such asNSBlockPredicate, but they’re all undocumented.