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

查看:56
本文介绍了如何使用 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天全站免登陆