我有这段代码可以在 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];
但它不起作用,为什么?