How to split a string with newlines
问题 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 the csv file. How do I do this? 回答1: You can break the string into arrays of string and then manipulate as you want. NSArray *brokenByLines=[yourString componentsSeparatedByString:@"\n"] 回答2: Just in case anyone stumbles across this question like I did. This will work with any newline characters: NSCharacterSet *separator