Reputation: 25
My goal is to parse multiple CSV data sets from an online API into an UITableView. Currently, I am looking at the CHCSVParser as an option to achieve this. With the CHCSVParser, it seems that data must be saved into a local file in order to be parsed(correct me if I am wrong). To save the CSV data locally, is it best that I save the data to the Documents directory? Or is there another, more efficient, way of parsing data from an online API? Thanks!
Upvotes: 0
Views: 76
Reputation: 1739
You could write a data stream to memory:
NSOutputStream *stream = [[NSOutputStream alloc] initToMemory];
CHCSVWriter *writer = [[CHCSVWriter alloc] initWithOutputStream:stream encoding:NSUTF8StringEncoding delimiter:','];
// write fields here
[writer closeStream];
NSData *buffer = [stream propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
Upvotes: 1