Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

= vs == in NSPredicate

I have seen in the apple document they have mentioned that =, == will behave same. https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html#//apple_ref/doc/uid/TP40001795-SW1

But in apple examples they use == in most cases and = for nil check.

Is it safe to use = for the below case?

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

or should we use:

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

Is there any difference between the two when dealing with predicates?

like image 280
Anshu Avatar asked Oct 09 '17 20:10

Anshu


1 Answers

They are equivalent when used in NSPredicate. I suppose there might be a slight preference for == since it would "look" more correct when combined with other Swift code. But either would be safe to use.

like image 91
picciano Avatar answered Oct 06 '22 01:10

picciano