I am trying to convert lineBreaks in my UITextView to <br /> tags,
why does the following line crash? It complains about [NSCharacterSet newlineCharacterSet] because when I pass it a normal string it works fine
[myMutableString stringByReplacingOccurrencesOfString:
[NSCharacterSet newlineCharacterSet] withString:@"<br />"];
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFCharacterSet length]: unrecognized selector sent to
instance 0x7b1cc80'
A
NSCharacterSetis not aNSString.So you’re passing a wrong argument.If you have only newline “\n” characters you can use:
If you have also “\r” and “\lf” you can try something like this (untested)