开发者

How decompose NSPredicate into components?

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(col开发者_如何学运维lection, $x, $x.name == "Name").@Count)"];


+[NSPredicate predicateWithFormat:] is actually the front-end for a rather sophisticated parser. If you introspect the resulting NSPredicate, you'll find that it's not actually an NSPredicate, but either an NSComparisonPredicate or an NSCompoundPredicate.

Both of those types of predicates have lots of handy methods for convenient introspection.

In other words: NSPredicate is actually an "abstract" class. You'll usually only ever deal with comparison or compound predicates. There are other kinds, such as NSBlockPredicate, but they're all undocumented.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜