objective c - iPhone - Replacing line breaks in my TextView with ? -
objective c - iPhone - Replacing line breaks in my TextView with <br />? -
i trying convert linebreaks
in uitextview
<br />
tags, why next line crash? complains [nscharacterset newlinecharacterset]
because when pass normal string works fine
[mymutablestring stringbyreplacingoccurrencesofstring: [nscharacterset newlinecharacterset] withstring:@"<br />"]; terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfcharacterset length]: unrecognized selector sent instance 0x7b1cc80'
a nscharacterset
not nsstring
.so you're passing wrong argument. if have newline "\n" characters can use:
[mymutablestring stringbyreplacingoccurrencesofstring:@"\n" withstring:@"<br />"];
if have "\r" , "\lf" can seek (untested)
nsrange range; while((range = [mymutablestring rangeofcharacterfromset: [nscharacterset newlinecharcaterset]]).location != nsnotfound) { [mymutablestring replacecharactersinrange:range withstring:@"<br />"]; }
iphone objective-c line-breaks
Comments
Post a Comment