我有一个可变的属性字符串,我已经添加了图像文本附件。
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];
我现在如何获得该文字附件&在图像应该位于文本正文的位置用字符串替换它?
答案 0 :(得分:1)
只需告诉文本存储,您更新了相应附件字符范围的属性:
textStorage.edited([.EditedAttributes], range: range, changeInLength: 0)