views:

26

answers:

2

Hi Folks!

I have an NSTextView that I need to insert a line break in. The code looks like this:

NSString *myString = @"test"
[myTextView insertText:myString];

/**** INSERT LINE BREAK HERE ****/

[[myTextView textStorage] insertAttributedString:MY_ATTRIBUTED_STRING atIndex:myString.length];

Anybody have any idea how to do this?

+1  A: 

I believe you can use the literal \n for a newline

NSString *myString = @"test\n"
[myTextView insertText:myString];
Jason
A: 

I agree with Jason. Use \n. I KNOW it works for iPhone, so it should definitely work for Mac.

Also, you forgot a semicolon on the end of the first line ;)

HiGuy Smith