0
我有一個CSV文件,包含四個字段,「Woonplaats」,「Gemeente」,「Provincie」,「Latitude」和「Longitude」。NSScanner和一個CSV文件
值的示例:
Graveland,Wijdemeren,北荷蘭省,52.24412000,5.12150000
使用下面的代碼,我得到了我的文本字符串,然後我要救它在陣列中。我應該如何使用NSScanner
從這個字符串獲取數據並保存在包含字典的數組中?
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"cities" ofType:@"csv"];
NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil ];
NSScanner *scanner = [NSScanner scannerWithString:myText];
[scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@"\n ,"]];
NSMutableArray *newPoints = [NSMutableArray array];