I want to replace a substring (e.g. @\"replace\") of an NSAttributedString with another NSAttributedString.
I am looking for a
In my case, the following way was the only (tested on iOS9):
NSAttributedString *attributedString = ...;
NSAttributedString *anotherAttributedString = ...; //the string which will replace
while ([attributedString.mutableString containsString:@"replace"]) {
NSRange range = [attributedString.mutableString rangeOfString:@"replace"];
[attributedString replaceCharactersInRange:range withAttributedString:anotherAttributedString];
}
Of course it will be nice to find another better way.