[Proposal] Type safe NSPredicate


(Jerome ALVES) #1

Hi everyone,

I think we all agree that #selector(...) and #keyPath(...) are great to write safe Swift code when interoperating with these Objective-C patterns.

How complicated would it be to have a similar functionality to write type safe NSPredicates ?

class Test {
    var value: Int = 0
}

let test = Test()
let myPredicate = #predicate(myValue == 3)

myPredicate.evaluateWithObject(test) // => false

test.value = 3

myPredicate.evaluateWithObject(test) // => true

Regards,
Jérôme Alves