我是 iPhone 的新手,我正在尝试在 UIwebView 中打开 .docx 文件,我编写了以下代码
NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"Arabic literature"
ofType:@"docx"];
NSURL *url = [NSURL fileURLWithPath:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
NSData *data = [NSData dataWithContentsOfFile:urlAddress];
//[_webView loadRequest:requestObj];
[_webView loadData:data MIMEType:@"application/vnd.ms-word" textEncodingName:@"UTF-8" baseURL:nil];
但它给了我以下例外:
DiskImageCache: Could not resolve the absolute path of the old directory.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
考虑到我在支持文件中复制了文件“Arabicliterature.docx”。我该如何解决这个异常?