Test if PDF exists at URL always returns error

The NSURL method "checkResourceIsReachableAndReturnError" always returns the following error::

'Domain=NSCocoaErrorDomain Code=262 "The file couldn’t be opened because the specified URL type isn’t supported."'

The code:

    NSError     *   error = nil;
    NSURL       *   baseURL = [NSURL URLWithString:@"http://www.adomainname.com"
    NSString    *   newsletterFileName = [NSString stringWithFormat:
                                          @"uploads/%4ld_%02ld_-_org_newsletter.pdf"
                                          , newsLetterYear // defined as current year
                                          , newsLetterMonth]; // defined as current month
// should end up as: http://www.adomainname.com/uploads/YYYY_MM_-_org_newsletter.pdf
    NSURL   *   resourceURL2= [NSURL fileURLWithPath: newsletterFileName relativeToURL: baseURL];
    if ( ! [resourceURL2 checkResourceIsReachableAndReturnError: &error] ) {
        if ( nil != error ) {
            NSLog ( @"%@", [error localizedDescription] );
            --newsLetterMonth;
        }
    }
    _newsletterMaximumMonth = newsLetterMonth;

Line 8 always returns NO even though the following two lines will load the file and display it:

    NSURLRequest *request = [NSURLRequest requestWithURL: resourceURL2];
    [_webPdfViewOutlet loadRequest: request];

So if the error was actually correct and the URL type wasn't suported why can I load and display the file?

If I can load the file why doesn't checkResourceIsReachableAndReturnError return that the file is reachable?


Ive also tried creating the URL from the string: @"http://www.adomainname.com/uploads/%4ld_%02ld_-_org_newsletter.pdf" and using:

fileURLWithPath: idDirectory: NO but same error and same effect.

How are you supposed to check to see if a file exists on a non-local URL?

Do I do the loadRequest and check the return error? Seems slow and wasteful.


Any help apreciated.


TIA

ClarkW

Test if PDF exists at URL always returns error
 
 
Q