简体   繁体   English

更新NSMutableAttributedString中的文本

[英]Updating text within NSMutableAttributedString

I create a NSMutableAttributedString in the init method of a view by doing this: 我通过这样做在视图的init方法中创建一个NSMutableAttributedString:

self.name = [[NSMutableAttributedString alloc] initWithString:@"Gabe Jacobs"];

How do I update the string within it without initing again? 如何在不重新启动的情况下更新其中的字符串? I don't want to have to create a new one every time. 我不想每次都要创建一个新的。 Any idea? 任何想法?

NSMutableString *string = [NSMutableString stringWithString:@"first"];
[string replaceCharactersInRange:NSMakeRange(0, string.length) withString:@"second"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM