I want to replace a substring (e.g. @"replace") of an NSAttributedString with another NSAttributedString.
I am looking for an equivalent method to NSString‘s stringByReplacingOccurrencesOfString:withString: for NSAttributedString.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Convert your attributed string into an instance of
NSMutableAttributedString.The mutable attributed string has a
mutableStringproperty. According to the documentation:So you can use the resulting mutable string to execute the replacement with
replaceOccurrencesOfString:withString:options:range:.