NSMutableString:可变字符串(内容可以进行添加,删除)
NSMutableString *n1 = [NSMutableString stringWithFormat:@"age is 10"];
NSString *n2= [ NSString stringWithFormat:@"age is 10"] ;
[ n1 appendString:@"11,12"]; //字符串内容将拼接到n1字符串最后面
[n1 deleteCharactersInRange:NSMakeRange(4,2)];//删除n1一定范围内的字符串
//删除is
NSRange range = [n1 rangeOfString:@"is"];
NSString *s = [n1 deleteCharactersInRange:range];
NSString *ss1 = [NSString stringWithFormat:@"age is 10"];
NSString *ss2 =[ss1 stringByAppendingString:@"11 12"];
//以上两行的过程是ss1和“11 12”各拷贝一份在ss2中进行拼接,但是ss1,“11 12” 的内容不变
|
|