gpt4 book ai didi

ios - 如何删除和替换 NSAttributedString 中的 NSTextAttachment

转载 作者:可可西里 更新时间:2023-11-01 06:05:33 24 4
gpt4 key购买 nike

我有一个可变的属性字符串,我在其中添加了图像文本附件。

NSMutableAttributedString* attributedString = [_textField.attributedText mutableCopy];

NSMutableDictionary* dict = [_homeFeedCommentsViewController.inputData.array_extraElements objectAtIndex:0];

NSNumber* indexObject = [NSNumber numberWithUnsignedLong:attributedString.length];

[dict setObject:indexObject forKey:@"LocationIndex"];

[attributedString insertAttributedString:imageAsAttributedString atIndex:attributedString.length];

我现在如何获取该文本附件并将其替换为文本正文中图像应位于的位置的字符串?

最佳答案

简单地告诉文本存储您更新了相应附件字符范围的属性:

textStorage.edited([.EditedAttributes], range: range, changeInLength: 0)

关于ios - 如何删除和替换 NSAttributedString 中的 NSTextAttachment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31465519/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com