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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.