Is it possible to compare NSString with NSMutableString

eg...

NSString string1 = @"Hello world";
NSMutableString string2 = [NSMutableString stringWithString: string1];

then ... then we can compare them using the following statement ..? or is there another way?

if(string1 isEqualToString:string2)

help me...

+3
source share
1 answer

Yes of course. NSMutableString is NSString, so your code is absolutely correct, with the exception of some syntax errors (you skipped *on each NSStringand [ ]in the instructions if. You should write:

NSString *string1 = @"Hello world";
NSMutableString *string2 = [NSMutableString stringWithString:string1];

if ([string1 isEqualToString:string2])
{
    // string are equal
}
+3
source

Source: https://habr.com/ru/post/1777230/


All Articles