swift - how to trim of all lines from string except the first -


how go removing second , third lines of following example?

var teststring: string = "hello \n \n friend" 

so print this:

"hello"

var firstline = teststring.componentsseparatedbystring("\n").first 

Comments