I have an NSAttributedString, I need to insert some text in the middle of the text in my attributedString, how can i do that?
1 Answer
NSAttributedString *someAttrString = ...; // the original string you want to modify
NSAttributedString *someOtherAttrString = ...; // the text you want to insert
NSUInteger whereItGoes = ...; // where you want to insert the string
NSMutableAttributedString *mutableString = [someAttrString mutableCopy];
if (mutableString) {
[mutableString insertAttributedString: someOtherAttrString atIndex: whereItGoes];
// mutableString now contains the modified data; it's up to you
// how it gets used in your app.
[mutableString release];
}