如何用换行符拆分字符串 [英] how to split a string with newlines
本文介绍了如何用换行符拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从csv文件中读取,并希望使用stringWithContentsOfFile分割我得到的长字符串,这是一个多行字符串,各行代表csv文件中的行。我该怎么做?
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?
推荐答案
您可以将字符串分解为字符串数组,然后根据需要进行操作。
You can break the string into arrays of string and then manipulate as you want.
NSArray *brokenByLines=[yourString componentsSeparatedByString:@"\n"]
这篇关于如何用换行符拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文