开发者

Can we compare the NSString with NSMutableString

开发者 https://www.devze.com 2023-01-27 00:59 出处:网络
for example... NSString string1 = @\"Hello world\"; NSMutableStr开发者_开发百科ing string2 = [NSMutableString stringWithString: string1];

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消