davedelong/CHCSVParser

How to "create" the needed file for csv export?

Closed this issue · 1 comments

As I am quite new to iOS development in general and also not familiar with this library I would like to know how to create the file or the path that is needed for exporting to a .csv file with this library?

Also I am not sure how a potential user of my application can than access the exported .csv file since there is no file system on iOS?

This is how:

func getFilePath() -> String {

    var directory = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true)[0] as NSString;
    return directory.stringByAppendingPathComponent("yourfilename.csv");
 }

And to get the file:

var path = getFilePath();

var writer = CHCSVWriter(forWritingToCSVFile: path);
// write stuff...

// access the written file
var fileData = NSData(contentsOfFile: path);