ios - How to compare two case insensitive strings? -
i have 2 string objects containing same string case different,now wanna compare them ignoring case sensitivity,how that??here code...
#import <foundation/foundation.h> void main() { nsstring *mystring1 = @"mphasis"; nsstring *mystring2 = @"mphasis"; if ([mystring1 caseinsenstivecompare:mystring2]) { nslog (@"its equal"); } else { nslog (@"its not equal"); } }
if caseinsensitivecompare: in docs you'll see returns nscomparisonresult rather bool. in docs , you'll see want nsorderedsame.
if ([mystring1 caseinsensitivecompare:mystring2] == nsorderedsame)
should trick. or compare lowercase strings robert suggested.
Comments
Post a Comment