Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ac1

macrumors newbie
Original poster
Jan 17, 2011
7
0
I'm having a bit of trouble with this. My app takes a csv file from the web, parses it and then "should" be displaying the results into a UITableView.

I used a similar idea to get another app to take parsed csv data and use it to display map annotations, but this time I am working with strings (rather than floatvalues)

Is there any way of taking parsed csv data and putting it as a strings into an nsarray?
 
I'm not familiar with CSV files, but if you parsed it to get NSStrings, then alloc and init a NSMutableArray and use the following method for each NSString you want to add:

- (void)addObject: (id)anObject
 
Code:
	NSScanner *scanner = [NSScanner scannerWithString:fileString];
	csvcomments = [[NSMutableArray array] retain];
	Comments *event;
	NSString *line;
	NSArray *values;
	while ([scanner isAtEnd] == NO) {
		[scanner scanUpToString:@"\n" intoString:&line];
		//skip the first line
		if(count > 0) {
			values = [line componentsSeparatedByString:@","];
			event = [[[Comments alloc] init] autorelease];
			event.weekday = [[values objectAtIndex:0] floatValue];
			event.time = [[values objectAtIndex:1] floatValue];
			event.comment = [[values objectAtIndex:2] floatValue];
			[csvcomments addObject:event];
Problem is I don't want these things as floatvalues, but as strings instead?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.