如下图所示,我试图保存所有字符串。但是,即使它显示了创建的txt但没有创建txt。请参阅此问题Adding string on existing txt file -iOS
-(void)saveData:(NSString*)data
{
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory=[paths objectAtIndex:0];
NSString *fileName=[NSString stringWithFormat:@"%@/%d.txt",documentDirectory,1];
NSString *content=data;
NSFileHandle *fileHandler= [NSFileHandle fileHandleForWritingAtPath:fileName];
[fileHandler seekToEndOfFile];
[fileHandler writeData:[content dataUsingEncoding:NSUTF8StringEncoding]];
[fileHandler closeFile];
NSLog(@"%@",fileName);
}