NSMutableAttributedString

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012581760/article/details/82863072
 NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:@"${李四} 回复 ${王麻子:90} 想回家[email protected] 13456890000 #{旅游节}[拜拜][鄙视]13456890000四:32}And@{王麻子:12}宝https://www.google.com/贵的"];
 
    NSMutableString *myStr = str.mutableString;
    //The character contents of the receiver as an NSMutableString object.The receiver tracks changes to this string and keeps its attribute mappings up to date.接收者的字符内容作为NSMutableString对象。接收器跟踪对此字符串的更改并使其属性映射保持最新。
    [str replaceCharactersInRange:NSMakeRange(0, 5) withString:@""];
    NSLog(@"%@",myStr);
//打印结果
(lldb) po str
 回复 ${王麻子:90} 想回家[email protected] 13456890000 #{旅游节}[拜拜][鄙视]13456890000四:32}And@{王麻子:12}宝https://www.google.com/贵的{
}
(lldb) po myStr
 回复 ${王麻子:90} 想回家[email protected] 13456890000 #{旅游节}[拜拜][鄙视]13456890000四:32}And@{王麻子:12}宝https://www.google.com/贵的
 
  // 可以看出myStr的字符串内容是随着str的变化而变化的

猜你喜欢

转载自blog.csdn.net/u012581760/article/details/82863072