【发布时间】:2013-05-02 11:52:50
【问题描述】:
我创建了一个日志文件,使用以下代码。
-(void)logme:(NSString *)mymessage
{
NSString *content = mymessage;
//Get the file path
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *fileName = [documentsDirectory stringByAppendingPathComponent:@"locationlog.txt"];
//create file if it doesn't exist
if(![[NSFileManager defaultManager] fileExistsAtPath:fileName])
[[NSFileManager defaultManager] createFileAtPath:fileName contents:nil attributes:nil];
//append text to file (you'll probably want to add a newline every write)
NSFileHandle *file = [NSFileHandle fileHandleForUpdatingAtPath:fileName];
[file seekToEndOfFile];
[file writeData:[content dataUsingEncoding:NSUTF8StringEncoding]];
[file closeFile];
}
并将此日志文件称为,
[self logme:myHTML];
但我无法找到此日志文件在我的 ios 设备上物理创建的位置,它将存储在 ios 设备中的什么位置?
【问题讨论】:
-
您可以在此 [url][1] [1] 中找到解决方案的答案:stackoverflow.com/questions/12323194/…
-
如果我从 MAC 中删除设备,日志文件不会更新
-
为什么当我从 MAC 中弹出设备时日志文件没有更新。然后再次连接设备并打开 Sandbox 日志文件未更新。
标签: ios