how would i compare two strings if they are not equal? i cannot use isEqualToString ... i am very new to the language..plz help thanks!!!
+1
A:
Use the NSString compare method (or one of the more detailed variations).
walkytalky
2010-08-19 10:26:18
A:
Steps:
Check if both the strings are of equal length.
using ObjectiveC :
[str1 length] == [str2 length];
If both the strings are of equal length, then compare character by character.
using ObjectiveC:
BOOL isStringsEqual = YES; for(int i=0; i < [str1 length]; i++) { if([str1 characterAtIndex:i] != [str2 characterAtIndex:i]) { isStringsEqual = NO; break; } }
if(isStringsEqual) { NSlog(@"Both strings are equal"); } else { NSlog(@"Both strings are not equal"); }
Biranchi
2010-09-15 09:33:37