"Could I do the following"
No. NSPredicate comes with its own completely specified language. Predicate strings must conform to that language; otherwise, they cannot be parsed.
"If not, what is an alternative?"
An alternative to do what? You are not telling us anything about the goal here. For example, instead of calling NSPredicate(format:)
, you might be able to call NSPredicate(block:)
which lets you write the predicate test in Swift code. But you can't do that in all situations. And you have not said what your situation is.