for example...
NSString string1 = @"Hello world";
NSMutableStr开发者_开发百科ing string2 = [NSMutableString stringWithString: string1];
then... then can we compare these using following statement..? or there is any other way?
if(string1 isEqualToString:string2)
help me out please...
yes of course. an NSMutableString is an NSString, so your code is perfectly correct, except for some syntax errors (you missed the *
on each NSString
and the [
]
on the if
statement. You should write :
NSString *string1 = @"Hello world";
NSMutableString *string2 = [NSMutableString stringWithString:string1];
if ([string1 isEqualToString:string2])
{
// string are equal
}
精彩评论