Я пытаюсь загрузить файл HTML из Интернета и сохранить его в своем приложении для последующего (автономного) просмотра. Я использую следующий метод для загрузки файла, но мой отчет NSLogs об отсутствии данных был загружен. В чем здесь проблема? (предположить активное подключение к Интернету, предположить заранее определенный путь к локальному каталогу документов)
urlAddress = @"http://subdomain.somesite.com/profile.html";
// Create and escape the URL for the fetch
NSString *URLString = [NSString stringWithFormat:@"%@%@", @"ttp://subdomain.somesite.com/profile.html"];
NSURL *URL = [NSURL URLWithString:
[URLString stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding]];
// Do the fetch - blocks!
NSData *theData = [NSData dataWithContentsOfURL:URL];
if(theData == nil) {
NSLog(@"NO DATA DOWNLOADED");
}
// Do the write
NSString *filePath = [[self documentsDirectory] stringByAppendingPathComponent:@"Profile/profile.html"];
[theData writeToFile:filePath atomically:YES];
NSLog(@"WRITING profile.html to path %@!", filePath);