如何清除 NSMutableAttributedString 的内容?

发布于 2024-09-24 11:42:50 字数 171 浏览 0 评论 0原文

我有一个 ivar,它在对象的 init 中进行分配:

attString = [[NSMutableAttributedString alloc] init];

在循环中,我想清除 attString 的内容并重新使用它。我该怎么做?

谢谢!

I have an ivar which is alloc-inited in the init of an object:

attString = [[NSMutableAttributedString alloc] init];

On a loop, I want to clear the contents of attString and re-use it. How do I do this?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

分开我的手 2024-10-01 11:42:50
[[attString mutableString] setString:@""];
[[attString mutableString] setString:@""];
云之铃。 2024-10-01 11:42:50
[attString release];
attString = [[NSMutableAttributedString alloc] init];

肯尼的方法可能更快。

[attString release];
attString = [[NSMutableAttributedString alloc] init];

Kenny's method probably quicker.

小巷里的女流氓 2024-10-01 11:42:50

我没有找到@kennytm上面提到的方法,但我这样做了:

[attriString setAttributedString:[NSAttributedString new]];

Available from mac10.0 and ios3.2 or later。祝新搜索者好运!

I didn't find out the methods that @kennytm mentioned above, but I did it with this:

[attriString setAttributedString:[NSAttributedString new]];

Available from mac10.0 and ios3.2 or later. Good luck for new searchers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文