4

I have a mutable attributed string which I have added an image text attachment to.

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];

How do i now get at that text attachment & replace it with a string at the location where the image is supposed to be located in the body of the text?

Geoff H
  • 2,688
  • 1
  • 25
  • 45

1 Answers1

1

Simply tell the text storage you updated the attributes for the range of your corresponding attachment character:

textStorage.edited([.EditedAttributes], range: range, changeInLength: 0)
Sam Soffes
  • 14,138
  • 9
  • 68
  • 78