Text and NSTextView

Since some months i started experiencing with xcode and i am starting to enjoy it more and more! This site is a great support for me! Now i have a little problem but i can’t find any answer on the internet. So i would really appreiciate it if someone could help me :).

I’m working on a little application which does generate 20 lines of text.
Every line is in a variable line_1, line_2 and so on.

This is how i set the contents of the NStextView:


	tell text view 1 of scroll view 1 of window 1
		set contents to line_1
	end tell

But the problem is that i can only set one line of text or all the lines behind each other with line_1 & line_2 & line_3 and so on.
If possible, this is what i would like to do (example):

set line_1 to “This is a little sample”
set line_2 to “Hopefully someone can help me”
set line_3 to “Some other line of text”

How can i get this outbut in the NSTextView:
This is a little sample
Hopefully someone can help me
Some other line of text

So every variable must be on a new line.
I hope you understand my problem, my english is not too good :).

All help is really appreciated, thanks in advance!

Thanks for your really fast reaction, this is exactly what i was looking for! Works just perfect!

But now i came up with a little other question. Is it also possible to do the same only the other way?
So the input is for example a NSTextField with 5 lines of text
And the output should be line_1, line_2, line_3, line_4 and line_5.

If this is possible, it would be great!

Some minutes ago i did found a solution!


tell text view 1 of scroll view 1 of window 1
       set the_text to contents
end tell

set text_in_lines to paragraphs of the_text

set line_1 to item 1 of the_text
set line_2 to item 1 of the_text
set line_3 to item 1 of the_text
set line_4 to item 1 of the_text
set line_5 to item 1 of the_text

It does work perfectly, is this the right way or is there a better solution?