OR function in Objective-C
is there an OR function in Objective-C?
for example:
if(string1 == string2 || string开发者_StackOverflow3 == string 4)
||
doesnt seems to work.
Thanks.
|| is a valid Objectivc-C and C Operator. It should work.
Try is code:
if([string1 isEqualToString:string2] || [string3 isEqualToString:string4])
{
}
The or-operator ||
works fine, but the ==
operator doesn't work for C-strings nor for NSString
if you want to test for string-equality. As written you only test for the pointers being equal.
Instead use:
strcmp()
for C-style strings-isEqualToString:
forNSString
精彩评论