Skip to content

Instantly share code, notes, and snippets.

@tkausch
Created October 23, 2020 14:55
Show Gist options
  • Save tkausch/2f3484767ef41a65b400a734a5aabde6 to your computer and use it in GitHub Desktop.
Save tkausch/2f3484767ef41a65b400a734a5aabde6 to your computer and use it in GitHub Desktop.
How to get the lines in a string as an array
let lines = str.components(separatedBy: "\n")
extension String {
var lines: [String] {
return self.components(separatedBy: "\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment