Possible Duplicate:
If “a == b” is false when comparing two NSString objects?
Simple Question of comparing 2 strings:
if (string1 == string2)
{
NSLog(@"it is equal!");
}
thats it but it wont work for me it is always !=
i testet it with string2 = string1; but it wont work.
so i tested if (string1 isEqualToString:string2) but in that case there is a syntax error
Thanks for any help!
Regards Curtis
==compares the address of the objects, not their content. Two different objects will obviously never have the same address.To compare strings use
NSString‘sisEqualToString:method:Note the square brackets
[ ]. This is the proper Objective-C syntax for sending messages (i.e. calling functions).To generally compare object in regards to their content, use
isEqual:.