How to split a string with newlines

前端 未结 6 1526
天涯浪人
天涯浪人 2020-12-29 21:44

I read from a csv file, and want to split the long string that I get using stringWithContentsOfFile, which is a multi line string, with individual lines representing rows in

6条回答
  •  清歌不尽
    2020-12-29 21:57

    Swift 3 version:

    let lines = yourString.components(separatedBy: .newlines)
    

    Nice and short.

提交回复
热议问题