objective c - need one methods to quantities replace for NSMutableAttributedString same as stringByReplacingOccurrencesOfString for NSString? -
is there replace method nsmutableattributedstring similar stringbyreplacingoccurrencesofstring: nsstring?
nsstring *newstring = [mystring stringbyreplacingoccurrencesofstring:@"," withstring:@""]; i need same method nsmutableattributedstring. (i need replace string image).
nsmutableattributedstring *mutableattstring = [[nsmutableattributedstring alloc] init]; nstextattachment *attachment = [[nstextattachment alloc] init]; attachment.image = [uiimage imagenamed:@"a.png"]; nsattributedstring *attachmentstring = [nsattributedstring attributedstringwithattachment:attachment]; [mutableattstring replacecharactersinrange:getanswer withattributedstring:attachmentstring]; this way replace 1 time. need quantities replace
replacecharactersinrange:withattributedstring: correct method use, need find range want replace first.
to that, use string method of attributed string , 1 of rangeof... methods find appropriate range want replace.
also, example shows calling [[nsmutableattributedstring alloc] init] , replacecharactersinrange:withattributedstring:, should have in mutable string before try replace it.
Comments
Post a Comment