在我的 iPhone 应用程序中,我需要将二进制数据附加到文件中:
NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSData* data = [NSData dataWithBytes:buffer length:readBytes_];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"myFile"];
NSFileHandle *myHandle = [NSFileHandle fileHandleForUpdatingAtPath:appFile];
[myHandle seekToEndOfFile];
[myHandle writeData: data];
[myHandle closeFile];
// [data writeToFile:appFile atomically:YES];
// Show contents of Documents directory
NSLog(@"Documents directory: %@",
[fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
但是在 NSlog 中我看不到有我的文件。怎么了?