18

This is a pretty simple question- how can I check if a NSURL is linking to a local file?

I know, RTFM, but I checked the documentation and I don't seem to see any methods related to this.

The only methods I did find were -isFileReferenceURL and -isFileURL, but I think these only check if the URL directly links to a file.

Note: I'm making an iPhone app, so by "local file" I mean a .html file stored in the project's resources.

Thanks for any help in advance.

skyylex
  • 855
  • 1
  • 10
  • 24
element119
  • 7,475
  • 8
  • 51
  • 74

2 Answers2

40

The -isFileURL will check if your URL uses the file: scheme. It doesn't check whether it's referencing an actual file.

Iulian Onofrei
  • 9,188
  • 10
  • 67
  • 113
Claus Broch
  • 9,212
  • 2
  • 29
  • 38
  • Thanks, wasn't sure exactly what that meant. – element119 Jun 16 '10 at 22:37
  • @Goles how come is it iOS8+ if the answer is from 2010? I just checked the header and there is no annotation about the availability at all, so I assume it has been there for ages. – Otávio Mar 15 '16 at 11:15
7

There is -isFileReferenceURL as of iOS 5 that checks if the url is an file reference. Before 5.0, it did nothing according to the documentation..

Available in iOS 5.0 and later. (Symbol is present in iOS 4, but performs no operation.)

I hope this helps the new-comers...

Q8i
  • 1,767
  • 17
  • 25