I wish to detect when a PDF has been clicked and display it in a separate UIWebView. Here's what I have currently:
- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; {
NSURL *url = [request URL];
NSString *urlString = [url absoluteString];
if (fileType != @"PDF") {
if([urlString rangeOfString:@".pdf"].location == NSNotFound){
return true;
} else {
NSURL *filePath = [NSURL URLWithString:urlString];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:filePath];
[pdfViewer loadRequest:requestObj];
[self.view addSubview:topView];
fileType = @"PDF";
return false;
}
} else {
return true;
}
}
This works fine. However it does have one Glaring Flaw:
What about "http://www.example.com/ikb3987basd"
How can I recognise a file type without the extension? Is there some sort of data about the file that I can check on?