-
Notifications
You must be signed in to change notification settings - Fork 0
NSPredicate NSExpression
Ken Harris edited this page Aug 29, 2020
·
1 revision
NSPredicate/NSExpression are useful classes, but they also throw (undocumented) exceptions -- both init(...)
with bad input, and properties like .predicateFormat
on instances which don't seem to support it. They were designed for Objective-C, and never updated with fully Swift-friendly (and safe) interfaces. (NSExpression is essentially a giant Swift enum, implemented as a type enum + a pile 10 of properties. The properties are non-nullable/non-optional, and throw exceptions when the type slot doesn't indicate that property is active.) You can definitely use these classes from Swift, but be careful to only pass trusted data, in tested ways, as Swift has no way to catch exceptions.