如何使用iOS将数据导出到csv文件? [英] How to export data to a csv file with iOS?

查看:405
本文介绍了如何使用iOS将数据导出到csv文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序具有可以将一些数据导出到csv文件,然后复制到PC的功能.使用什么API来实现此功能?

My application has a function which can export some data to a csv file, and then copied to PC. What api to use to implement this function?

推荐答案

您还可以执行以下操作:

You can also do something like:

[[array componentsJoinedByString:@","] writeToFile:@"components.csv" atomically:YES encoding:NSUTF8StringEncoding error:NULL];

您可以使用此方法的组合来组合CSV(将列名的一个数组的输出追加到值的一个数组等).

You can use combinations of this to put together a CSV (append the output of one array for the column names to one array for the values, etc).

当然,您必须要小心在已包含逗号的值两边加上引号,然后再对值中的所有引号进行转义.

Of course, you have to be careful to put quotes around values that already contain a comma, and to then escape any quotes in the value.

这篇关于如何使用iOS将数据导出到csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆