2

I'm building a small messaging app for the iPhone. When the user writes a message in my UITextView I save it to an online database. Then I download that and display it to another user. The problem is that the string that I send to the DB do not include the "\n"-sign from the Uitextview that the user typed in, When I try to display the message it displays it in one line instead of the formatting the user inputed.

I somehow want to get all newline-signs from the UitextView and save them inside the text in the DB so I can display the message with the right formatting.

How do I do this in Objective C?

1 Answer 1

3

UITextView supports the '\n' newline, and its text property will contains them.

You can try this to confirm that a UITextView supports them (note that textView is a UITextView):

if ([self.textView.text rangeOfString:@"\n"].location != NSNotFound) {
    NSLog(@"newline found");
}

Or this

self.textView.text = @"new\nline";

So may be you problem is elsewhere in the code that persist the user string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.