NSString initWithContentsOfFile 的奇怪问题
我的包中有一个 .csv 文件,我需要将其解析为 NSArray。问题是当我用文件内容初始化 NSString (该文件位于我的包中)时,它返回 nil。但是,如果我将文件的内容更改为其他内容(随机),它就会起作用。文件中是否有某种字符串/字符可能会扰乱初始化?
它只是一个简单的 csv 文件,包含 2 列、一个数字、一个逗号、一些文本和“\n”。
谢谢。
I have a .csv file in my bundle which I need to parse into an NSArray. The problem is when I init an NSString with contents of file (the file is located in my bundle), it returns nil. However, if I change the contents of the file, to anything else (random), it works. Is it possible there's some sort of string/character in the file that might be messing with the initialization?
It's just a simple csv file with 2 columns, a number, a comma, some text and "\n".
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CSV=> NSArray?
https://github.com/davedelong/CHCSVParser
*免责声明:我写的。
对我有用:
CSV => NSArray?
https://github.com/davedelong/CHCSVParser
*disclaimer: I wrote it.
Works for me: