Reputation: 3247
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?
Upvotes: 4
Views: 1616
Reputation: 14945
Simply tell the text storage you updated the attributes for the range of your corresponding attachment character:
textStorage.edited([.EditedAttributes], range: range, changeInLength: 0)
Upvotes: 1