0
我已經創建了一個日誌文件唱下面的代碼。在哪個位置創建的txt文件將被存儲在ios設備中
-(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]:http://stackoverflow.com/questions/12323194/logging-from-the-iphone-where -is-the-file?rq = 1 – Saeed 2013-05-02 03:52:27
這是非常有用的.http://stackoverflow.com/a/12323485/1119440 – Ramprasad 2013-05-02 04:25:40
如果我從MAC刪除設備日誌文件不更新 – Ramprasad 2013-05-02 07:03:25