我正在使用以下代码行下载 html 页面的内容并将其保存在目录中:
NSURL *yoyoyo = [[NSURL alloc] initWithString:@"www.google.com"];
NSData *data = [[NSData alloc] initWithContentsOfURL:yoyoyo];
//NSData *data = [NSData dataWithContentsOfURL:[NSURL UrlWithString:url]];
//use this data to write to any path as documentdirectory path + filename.html
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *htmlFilePath = [documentsDirectory stringByAppendingPathComponent:@"file.html"];
[data writeToFile:htmlFilePath atomically:YES];
NSLog(@"Tile Directory: %@", documentsDirectory);
文件目录是:
Tile Directory: /Users/xxxx/Library/Application Support/iPhone Simulator/5.1/Applications/D4B3A4CF-E7D0-4D25-A809-B3D3A170A329/Documents
但是,当我到达必须保存文件的路径时,我无法看到 html 文件。我无法解决这个问题。有人可以帮忙吗?