In a class such as NSFileManager there are 2 versions of practically every method. One for paths and one for URLs. What's the difference? And what's the best practice for converting a URL to a path.
Asked
Active
Viewed 8,497 times
2 Answers
29
path
is location of a resource (file/directory) in a file system
. Just like iOS File System, other environments file system can be Windows file system, Unix etc. Path can have spaces like /docs/random doc/
. (between random and doc)
URL
is is a reference to a resource anywhere (file system, web HTTP, FTP etc). URL can not have spaces like path.
Web URL: http://stackoverflow.com/
file URL: file://localhost/Users/username/docs/random%20docs/
path for above mentioned file URL
: /Users/username/docs/random%20docs/
in layman terms:
URL
= protocol (http, file etc) + host (domain name or IP or localhost) + path

Saurabh Hooda
- 2,536
- 2
- 20
- 30
-
In iOS, you can call url.path to get path from a url. – coolcool1994 Jul 19 '13 at 20:23
-
1`path` is an instance method and not a `property`. So better to use `[anyURLObject path]`. – Saurabh Hooda Jul 20 '13 at 06:14
13
URL includes the protocol being used (http:// etc). Path doesn't or doesn't need at least.

bluehallu
- 10,205
- 9
- 44
- 61
-
Also, URLs can percent-encode characters like spaces. Paths don't do that. – StilesCrisis May 04 '13 at 17:54
-
I've also heard about URI (in addition to URL), what's the difference between URI/URL ? – Rob van der Veer Jul 20 '13 at 07:58
-
1URIs identify resources, URLs locate them: http://stackoverflow.com/questions/4913343/what-is-the-difference-between-uri-url-and-urn – bluehallu Jul 20 '13 at 12:43