Creating an Array From a CSV File Using Objective C

后端 未结 3 501
野性不改
野性不改 2021-01-03 02:51

I\'m new to coding so please excuse me if this seems like a simple question.

I\'m trying to plot coordinates on a map.

I want to read a CSV file and pass the

3条回答
  •  無奈伤痛
    2021-01-03 03:30

    NSString* fileContents = [NSString stringWithContentsOfURL:filename ...];
    NSArray* rows = [fileContents componentsSeparatedByString:@"\n"];
    for (...
        NSString* row = [rows objectAtIndex:n];
        NSArray* columns = [row componentsSeparatedByString:@","];
    ...
    

    You'll probably want to throw in a few "stringTrimmingCharactersInSet" calls to trim whitespace.

提交回复
热议问题