XOR Objective-c

Nicolas Manzini picture Nicolas Manzini · Jul 11, 2012 · Viewed 17.4k times · Source

Is there a way to put a condition that return true only if one of the two component return true?

BOOL var1
BOOL var2

something shorter than if((var1 && !var2) || (!var1 && var2))

Thank you

Answer

Cyrille picture Cyrille · Jul 11, 2012

As Objective-C is a superset of C, you simply use the XOR operator from C, which is ^.