目标C:在csv文件上写字符串

时间:2011-04-07 13:21:54

标签: objective-c xcode string csv writetofile

  

可能重复:
  objective C: write in a csv (txt) string contained in some textfield

我有这个代码在csv文件(txt)中写一个字符串(要写的字符串是:csvString)

NSString *resourceFileName = @"Client";
NSString *pathToFile =[[NSBundle mainBundle] pathForResource: resourceFileName ofType: @"txt"];
NSError *error;

NSString *fileString = [NSString stringWithContentsOfFile:pathToFile encoding:NSUTF8StringEncoding error:&error];
if (!fileString) {
    NSLog(@"Error reading file.");
} 



[csvString writeToFile:pathToFile atomically:YES encoding:NSUTF8StringEncoding error:nil];

但它不起作用,为什么?

0 个答案:

没有答案