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

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -