0
votes

I knew this question is already asked here. But I am facing some issue which is not getting resolved.

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docsPath = [paths objectAtIndex:0];
    NSString *fileCacheDirPath = [docsPath stringByAppendingPathComponent:kATTACHMENTS_FOLDER];
    NSString *filePath = [fileCacheDirPath stringByAppendingPathComponent:_fileItemDataModel.name];
    NSURL *url = [NSURL fileURLWithPath:filePath isDirectory:NO];

Error:

url : file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B990D3-4311-B580-D2E00E75/Documents/AttachmentsFolder/Scrum_Methodology.pdf

Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x60800084d950 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, NSErrorFailingURLKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, _kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4, NSLocalizedDescription=The request timed out.}}, NSErrorFailingURLStringKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, NSErrorFailingURLKey=file:///Users/Sanoj/Library/Developer/CoreSimulator/Devices/722CC1FA-6542-4E14-9CC5-24F96EE305D9/data/Containers/Data/Application/B992A9C0-A0D3-4311-B580-D2E0049CFE75/Documents/AttachmentsFolder/Scrum_Methodology.pdf, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}

1
There should be NSURL.fileURL instead of NSURL URLWithString may that helpPrashant Tukadiya
I tried using as I mentioned in question itself, but no luck., It's called didstartdownload and didfail method of delegate.Sanoj
Have you check that file exits at path or not ?, With fileManager fileExistsAtPathPrashant Tukadiya
yes that is there, After printing path manually I am check with that url.Sanoj
But you should check NSFileManager's fileExistsAtPath Method and also observe AttachmentsFolder.Scrum_Methodology.pdf is it correct it is unlike AttachmentsFolder / Scrum_Methodology.pdfPrashant Tukadiya

1 Answers

0
votes

it worked with following code

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
           NSString *docsPath = [paths objectAtIndex:0];
           NSString *fileCacheDirPath = [docsPath stringByAppendingPathComponent:kATTACHMENTS_FOLDER];
           NSString *filePath = [fileCacheDirPath stringByAppendingPathComponent:_fileItemDataModel.name];
           [self.webView loadData:_fileItemDataModel.data MIMEType:@"application/pdf" textEncodingName:@"" baseURL:[NSURL URLWithString:filePath]];

Please, check