I want to export data from my application into a csv file.
I found CHCSVParser by Dave Delong
https://github.com/davedelong/CHCSVParser
I creat开发者_开发问答ed a test project, imported CHCSVWriter and wrote this:
CHCSVWriter * csvWriter = [[CHCSVWriter alloc] initWithCSVFile:@"~/testfile.csv" atomic:NO];
[csvWriter writeField:[NSString stringWithFormat:@"One"]];
[csvWriter writeLine];
[csvWriter writeField:[NSString stringWithFormat:@"Two"]];
[csvWriter writeLine];
[csvWriter closeFile];
[csvWriter release];
But I get no testfile.csv in the Finder :(
What am I doing wrong?
You will need to expand the ~
for this to work. You can either update the parser to handle the ~
for you or you can initialize the parser like this,
NSString * filePath = @"~/testfile.csv";
filePath = [filePath stringByExpandingTildeInPath];
CHCSVWriter * csvWriter = [[CHCSVWriter alloc] initWithCSVFile:filePath atomic:NO];
精彩评论