How to export data to a csv file with iOS?

前端 未结 4 1348
孤街浪徒
孤街浪徒 2020-11-29 05:04

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?

4条回答
  •  无人及你
    2020-11-29 05:24

    You can also do something like:

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

    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.

提交回复
热议问题