iphone app中读取本地txt,csv文件 转载

原文地址:iphone app中读取本地txt,csv文件 作者:醉吻花颜

- (void)readLocalData {
NSString *path = [[NSBundle mainBundle] pathForResource:@"test"ofType:@"txt"];
NSString *contents = [[NSString alloc] initWithContentsOfFile:pathencoding:NSUTF8StringEncoding error:nil];
NSArray *contentsArray = [contentscomponentsSeparatedByCharactersInSet:[NSCharacterSetnewlineCharacterSet]];

NSIntegeridx;    
for (idx = 0; idx < contentsArray.count; idx++){
NSString* currentContent = [contentsArray objectAtIndex:idx];
NSLog(@"%@",currentContent);
}
}


你可能感兴趣的:(iPhone,Path,csv)