= NSPredicate

问题描述:

= vs ==我在他们提到的苹果文档中看到===将表现相同。 https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html#//apple_ref/doc/uid/TP40001795-SW1= NSPredicate

但在苹果的例子,他们使用在大多数情况下===的零检查。

在以下情况下使用=安全吗?

NSPredicate(format: "firstName = %@", "Bunny") 

,或者我们应该使用:

NSPredicate(format: "firstName == %@", "Bunny") 

是否与谓词打交道时,两者之间有什么区别?

它们在NSPredicate中使用时是等效的。我想可能有一个==的轻微偏好,因为它会与其他Swift代码结合使用时看起来更加正确。但是两者都可以安全使用。