How to insert new line \n from UILabel text which typed in IB?

IosObjective CNsstring

Ios Problem Overview


I have id textInput and I insert new line(\n) OK with:

[textInput insertText:@"\n"];

But when input Text from label.text (Input in Interface Builder) ,it NOT OK. Just input \n text.

NSLog(@"%@",label.text);
[textInput insertText:label.text];

How to input special character when store it in label.text?

I don't want to compare [inputStr isEqualToString:@"\\n"];

*Log: \n

Thanks!

Ios Solutions


Solution 1 - Ios

Try option-return or pasting in the newline.

Solution 2 - Ios

@Hot Licks explained the reason well in comment.

The only way is

if ([self.mylabel.text isEqualToString:@"\\n"]) {
        
   [self.myTextView insertText:@"\n"];
}

Manually, use ALT+ENTER

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexView Question on Stackoverflow
Solution 1 - Iostc.View Answer on Stackoverflow
Solution 2 - IosShamsudheen TKView Answer on Stackoverflow