- 追加された行はこの色です。
- 削除された行はこの色です。
&tag(iOSSDK/ファイルIO);
*目次 [#j9477b9c]
#contents
*参考情報 [#b77138e7]
-[[How To Read a File From Your Application Bundle | iPhone Development Blog:http://iphoneincubator.com/blog/data-management/how-to-read-a-file-from-your-application-bundle]]
-[[davedelong/CHCSVParser · GitHub:https://github.com/davedelong/CHCSVParser]]…オープンソースのライブラリ
*CSVの読み込み [#vcd3f2bd]
-単純なCSVと仮定した上での読み込み
#pre{{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"csv"];
NSString *text = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [text componentsSeparatedByString:@"\n"];
NSLog(@"line count: %d", lines.count);
for (NSString *row in lines) {
NSArray *values = [row componentsSeparatedByString:@","];
NSLog(@"value count: %d", values.count);
}
}}