I am trying to download a webpage (html) then display the local html that has been download in a UIWebView.
This is what I have tried -
NSString *stringURL = @"url to file"; NSURL *url = [NSURL URLWithString:stringURL]; NSData *urlData = [NSData dataWithContentsOfURL:url]; if ( urlData ) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"index.html"]; [urlData writeToFile:filePath atomically:YES]; } //Load the request in the UIWebView. [web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]]; // Do any additional setup after loading the view from its nib. But this gives a 'SIGABRT' error.
Not too sure what I have done wrong?
Any help would be appreciated. Thanks!