开发者

Can we compare the NSString with NSMutableString

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜